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
Fail to apply typeinfo to a python module in a subdirectory #75
Comments
Does it work better if you use forward / on the command line (starting from the top)? |
Not really. Even if I do that and I convert the backslash to forward slash in type_info.json . |
Hm... What if you add an empty `__init__.py` file to the toto folder? (I'm
quite sure that this works at Dropbox.)
|
I tracked down the problem up to here :
Looks like crawl_up() was not designed to handle such cases. It miscalculates the top directory in this case :
|
Confirmed -- also that if I add an empty I replicated this by going to the pyannotate project root directory, running But I'm not sure what to do about it. It's been too long since I knew this code in and out, and while I know what crawl_up() is supposed to do, I'm no longer sure why that is needed here. If I replace its body with |
The code could use more tests in general, and in particular to capture precisely this kind of behavior. I would expect that this is needed if you are working with multiple in development packages and you are adjusting sys.path to pick all these packages (maybe even with pip). In this case, relating getcwd() current execution dir is no longer the right thing to do. |
I have encountered the same issue and have a small patch based on observations from @gvanrossum that works for me, maybe someone else will benefit from this. For a proper testing there will be more work involved, and I think that a command line option to guide the matching of sources to the json would be good. It could also be embedded in the json collection, so that we find the supposed topdir and embed what we find at collection time into the json that would help the annotator match up. |
FWIW I also ran into this, and I just commented out Before the change, I had a good type_info.json file, but nothing was being applied. After the change, everything was applied as far as I can tell. |
I am also experiencing the exact same thing. [
{
"path": "C:/Users/Me/Documents/GitHub/sabnzbd3/SABnzbd.py",
"line": 102,
"func_name": "GUIHandler",
"type_comments": [
"() -> None"
],
"samples": 1
},
] to [
{
"path": "SABnzbd.py",
"line": 102,
"func_name": "GUIHandler",
"type_comments": [
"() -> None"
],
"samples": 1
},
] After this it did exactly what I hoped it would do. Thanks very much for this tool ❤️ |
Unfortunately I have no time available to work on this. If someone could prepare a patch, including a bunch of tests that show how it works in various common and edge cases, I would very much appreciate it. |
Yes I will do it
…On Fri, Mar 22, 2019, 11:14 Guido van Rossum ***@***.***> wrote:
Unfortunately I have no time available to work on this. If someone could
prepare a patch, including a bunch of tests that show how it works in
various common and edge cases, I would very much appreciate it.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/APqoaWuMEu0TbiozBy9zwhrlJ2K9MufOks5vZPNGgaJpZM4Vfa9i>
.
|
I was thinking it could be as simple as adding a flag like |
This is mainly so we have a framework for adding specific integration tests, e.g. for #75 (in fact IIUC, test_subdir() here exercises that case, and it is indeed broken).
As long as that subdirectory is underneath the current directory. Fixes #75.
This is mainly so we have a framework for adding specific integration tests, e.g. for #75 (in fact IIUC, test_subdir() here exercises that case, and it is indeed broken). This adds tests for --auto-any and missing type_info.json error (and fixes both!).
As long as that subdirectory is underneath the current directory. Fixes #75.
As long as that subdirectory is underneath the current directory. Fixes #75. Enable test_subdir(), since it's being fixed here (and make it work on Windows).
The following will fail :
strange, there are type annotations in type_info.json with the correct path
edit the type_info.json to remove the "toto\"
try again
it worked...
It looks like pyannotate is trimming directories from type_info.json too agressively.
The text was updated successfully, but these errors were encountered: