Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Propagate type narrowing to nested functions#15133
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
e4ecb9105e3958f3c87ca01e044deecc877030457e79688597603f24a81856ac503b3ca601098fe051319d0b478639a9a16dbf9f1d46324077b67df339ae6456c3f3a24faaa5ecc2d3467098aa25cafbd40f3b534bfb5f10c4dce44fe08c2dc6516ec323e06c350905File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1084,7 +1084,15 @@ def cannot_narrow_if_reassigned(x: Optional[str]) -> None: | ||
| x: Optional[str] = "x" | ||
| def cannot_narrow_top_level() -> None: | ||
| ||
| global x | ||
| if x is None: | ||
| x = "a" | ||
| def nested() -> str: | ||
| # This should perhaps not be narrowed, since the nested function could outlive | ||
| # the outer function, and since other functions could also assign to x, but | ||
| # this seems like a minor issue. | ||
| return x | ||
| nested() | ||
| [case testNarrowedVariableInNestedFunctionMore1] | ||
| from typing import Optional, overload | ||