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

Give "as" variables in with statements separate scopes #12254

Merged
merged 19 commits into from
Feb 25, 2022
Merged

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Feb 25, 2022

Use renaming to allow two with statements to define the same variable
using incompatible types. The implementation is pretty simple-minded
and doesn't work in cases where there is even a hint of potential
ambiguity about which variant of a variable a reference targets, typically
due to functions.

This could be generalized to for statements in the future.

Fixes #12246.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/tests/test_utils.py:74: error: Unused "type: ignore" comment
+ src/bandersnatch/tests/test_utils.py:88: error: Unused "type: ignore" comment
+ src/bandersnatch/tests/plugins/test_storage_plugins.py:686: error: Unused "type: ignore" comment
+ src/bandersnatch/tests/plugins/test_storage_plugins.py:696: error: Unused "type: ignore" comment

zulip (https://github.com/zulip/zulip)
- tools/setup/generate_integration_bots_avatars.py:54: error: Incompatible types in assignment (expression has type "BufferedWriter", variable has type "BufferedReader")  [assignment]

pip (https://github.com/pypa/pip)
- src/pip/_internal/req/req_uninstall.py:623: error: Incompatible types in assignment (expression has type "BufferedWriter", variable has type "BufferedReader")
- src/pip/_internal/operations/install/wheel.py:107: error: Incompatible types in assignment (expression has type "BufferedWriter", variable has type "BufferedReader")

pyinstrument (https://github.com/joerick/pyinstrument)
- pyinstrument/renderers/html.py:79: error: Incompatible types in assignment (expression has type "StreamReaderWriter", variable has type "StreamWriter")

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

Successfully merging this pull request may close these issues.

Readable and writable binary files cause false positives
2 participants