dropbox / pyannotate

Auto-generate PEP-484 annotations
Apache License 2.0
1.42k stars 59 forks source link

Issue #75 Mismatch of json files to cwd, bugfix works for me #79

Closed jmikedupont2 closed 5 years ago

jmikedupont2 commented 5 years ago

Hello, I love this tool and thank you for creating it. I have encountered the issue mentioned in #75 The issue is that it finds the directory above my cwd which does not contain an __init__.py file. I have changed it to break at the cwd so that it will not go deeper.

So top dir is the first path without an init in there. That is basically the parent dir of my project. I am running the tests driver that generates the json not from the top dir but from one directory underneath it.

I do so because the topdir contains a src/ directory that has been created by pip install -e and pytest finds conftests from other projects there.

The checks on file path are brittle and could also be adjusted to accommodate for slight differences in the path. https://github.com/dropbox/pyannotate/blob/de6ccf8d3f384961048418d1e203bcc5b33465c7/pyannotate_tools/fixes/fix_annotate_json.py#L207

I hope this patch helps out anyone who might be having issues.

gvanrossum commented 5 years ago

I think a better fix is #83. Can you verify that that works?

gvanrossum commented 5 years ago

In particular, in #82 I added some integration tests, including one (disabled) named test_subdir() that should test this behavior. This PR doesn't make that test pass, but #83 does. So I'm just closing this.

But still let me know whether #83 addresses your problem! The cause may be subtly different.