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

un-narrowing to Unknown regression #9457

Open
beauxq opened this issue Nov 13, 2024 · 0 comments
Open

un-narrowing to Unknown regression #9457

beauxq opened this issue Nov 13, 2024 · 0 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working regression

Comments

@beauxq
Copy link

beauxq commented Nov 13, 2024

Describe the bug
If something has been narrowed to a specific type, an in check can remove the narrowing information - for example changing str to Unknown

Code or Screenshots

from typing import Any, reveal_type


def foo(a: object, d: dict) -> None:
    if not isinstance(a, str):
        return
    reveal_type(a)  # str
    if a not in d:
        return
    reveal_type(a)  # Unknown should be str


def goo(a: object, d: dict[Any, Any]) -> None:
    if not isinstance(a, str):
        return
    reveal_type(a)  # str
    if a not in d:
        return
    reveal_type(a)  # Any should be str

version

1.1.389
1.1.380
1.1.379 <- problem not present

@beauxq beauxq added the bug Something isn't working label Nov 13, 2024
erictraut added a commit that referenced this issue Nov 15, 2024
…using the `x in y` pattern where `y` is a container type whose element type is `Unknown` or `Any`. This addresses #9457.
erictraut added a commit that referenced this issue Nov 16, 2024
…using the `x in y` pattern where `y` is a container type whose element type is `Unknown` or `Any`. This addresses #9457. (#9469)
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working regression
Projects
None yet
Development

No branches or pull requests

2 participants