-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Allow redefinitions in except/else/finally #18515
Allow redefinitions in except/else/finally #18515
Conversation
@@ -274,7 +320,6 @@ def f() -> None: | |||
# E: Incompatible types in assignment (expression has type "int", variable has type "TypeVar") | |||
reveal_type(x) # N: Revealed type is "typing.TypeVar" | |||
y = 1 | |||
# NOTE: '"int" not callable' is due to test stubs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This note no longer applies, necessary stubs were connected in #17384.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a = "" | ||
a = fn_str(a) # E: Incompatible types in assignment (expression has type "int", variable has type "str") | ||
fn_int(a) # E: Argument 1 to "fn_int" has incompatible type "str"; expected "int" | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, also test except *
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #18514.
Only
try
clause should be treated as fallible, this should not prevent--allow-redefinition
from working in other try clauses (except, else, finally).