Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No files need to be modified. when __init__.py exists #61

Closed
dhallam opened this issue Jan 30, 2018 · 2 comments
Closed

No files need to be modified. when __init__.py exists #61

dhallam opened this issue Jan 30, 2018 · 2 comments

Comments

@dhallam
Copy link

dhallam commented Jan 30, 2018

Running python 2.7.11 with pyannotate v1.0.3 installed in a virtualenv on ubuntu 16.0.4. I cloned this repo and ran the following

cd example
python driver.py
pyannotate gcd.py

This resulted in the expected

Refactored gcd.py
--- gcd.py	(original)
+++ gcd.py	(refactored)
@@ -1,8 +1,10 @@
 def main():
+    # type: () -> None
     print(gcd(15, 10))
     print(gcd(45, 12))
 
 def gcd(a, b):
+    # type: (int, int) -> int
     while b:
         a, b = b, a%b
     return a
Files that need to be modified:
gcd.py
NOTE: this was a dry run; use -w to write files

If I then create an __init__.py file, and run pyannotate gcd.py, I get

No files need to be modified.
NOTE: this was a dry run; use -w to write files

which is not what I expect to get. This is preventing me from running across my project's codebase. The type_info.json file is created correctly. It's the pyannotate step that fails to identify any changes.

pipdeptree output showing what is installed

  - mypy-extensions [required: Any, installed: 0.3.0]
  - six [required: Any, installed: 1.11.0]
  - typing [required: >=3.5.3, installed: 3.6.4]
@gvanrossum
Copy link
Contributor

This is likely because you're running pyannotate from inside the package. You shouldn't do that. Or you should delete the unneeded toplevel __init__.py file. Check out the function crawl_up() to understand.

@dhallam
Copy link
Author

dhallam commented Jan 31, 2018

@gvanrossum That makes perfect sense. We had a stray __init__.py in our root folder causing the issue. All is working well now. Many thanks for a great tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants