Skip to content

Order-dependent "Cannot determine type" of module global str #5024

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

Closed
JelleZijlstra opened this issue May 13, 2018 · 4 comments
Closed

Order-dependent "Cannot determine type" of module global str #5024

JelleZijlstra opened this issue May 13, 2018 · 4 comments
Labels
bug mypy got something wrong priority-1-normal

Comments

@JelleZijlstra
Copy link
Member

This is a rather weird bug that showed up for us in production when I tried to upgrade to 0.600. The repro requires at least four files, so I decided to put it in its own little repo: https://github.com/JelleZijlstra/tmp-mypy-bug. Running mypy baddir (with mypy 0.600) reproes the bug there.

Basically, the test case has four files that import each other (__init__ -> ba -> b -> c). ba additionally uses a name from b (defines as LOCAL_HOSTNAME = socket.gethostname()), and the usage of this name causes a "Cannot determine type" error. Various minor transformations (making LOCAL_HOSTNAME a string literal; removing c.py) make the error go away.

Interestingly, renaming ba.py to a.py (as in the gooddir in the repo) silences the bug. This suggests that this is somehow related to the alphabetical order of the files involved. The bug didn't appear in 0.590. I'm guessing it's somehow related to the various FileSystemCache changes that went into 0.600. https://github.com/python/mypy/blob/master/mypy/find_sources.py#L78 is suspicious in that it does a sort and was new in 0.600, although really I'm just guessing.

@gvanrossum
Copy link
Member

Could you run it with -v or even -v -v and post the full log output from 0.590 and 0.600 somewhere?

@JelleZijlstra
Copy link
Member Author

@JelleZijlstra
Copy link
Member Author

Also 0.600 output for "gooddir", which doesn't have the bug: https://github.com/JelleZijlstra/tmp-mypy-bug/blob/master/gooddir0600.txt.

@msullivan
Copy link
Collaborator

Closing as a dupe/variant of #5015.
(This is fixed by #5016.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-1-normal
Projects
None yet
Development

No branches or pull requests

4 participants