-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
mypy fails to recognise assignment as a form of module aliasing #1778
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
Labels
Comments
carljm
added a commit
to carljm/mypy
that referenced
this issue
May 24, 2017
In semantic analysis, if we find a simple assignment statement where the rvalue is a module, make the lvalue a direct alias to that same module. Fixes python#1778.
carljm
added a commit
to carljm/mypy
that referenced
this issue
May 24, 2017
In semantic analysis, if we find a simple assignment statement where the rvalue is a module, make the lvalue a direct alias to that same module. Fixes python#1778.
ilevkivskyi
pushed a commit
that referenced
this issue
Jun 3, 2017
* Detect and support module aliasing via assignment. In semantic analysis, if we find a simple assignment statement where the rvalue is a module, make the lvalue a direct alias to that same module. Fixes #1778. * Handle chained assignment and iterable unpacking assignment. * Remove test case that was only for exploration, not intended for inclusion. * Add some more tests for module assignment. * Also add tests for access/assignment of nonexistent module attribute. * Break down code and add comments for clarity; add test for mismatch lengths. * Naming improvements. * Support tracking module assignment in non-global scope. * Add more tests for unpacking mismatch cases. * Keep rvals always on the right. * Don't use a form of unpacking that is Py35+ only. * It's the zip that is problematic, not just the unpacking. * Add tests for module assignment in class and local scopes. * Simplify to single method. * Go back to annotating genericpath as Any in stdlib-sample. * Respect explicit type annotation and don't propagate module reference. * Backtrack to simple ModuleType var in case of incompatible module aliasing. * Remove stray pdb comment. * Also handle reassignment of an original (non-alias) module reference. * Simplify: fail on assignment of different modules to same variable without explicit annotation. * Style and working tweaks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
The text was updated successfully, but these errors were encountered: