Skip to content

Incorrect redundant-expr error for isinstance on constrained TypeVars #724

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

Open
Loch64 opened this issue Aug 1, 2024 · 1 comment · May be fixed by #754
Open

Incorrect redundant-expr error for isinstance on constrained TypeVars #724

Loch64 opened this issue Aug 1, 2024 · 1 comment · May be fixed by #754
Labels
bug Something isn't working

Comments

@Loch64
Copy link

Loch64 commented Aug 1, 2024

Describe the problem, ie expected/actual result (if it's not blatantly obvious)

def f[T: (int, str)](t: T):
    if isinstance(t, int):  # always true and always false
        ...

Gist to reproduce

https://mypy-play.net/?mypy=basedmypy-latest&python=3.12&gist=fd75669322cbcbe6bb7c20b985768813

Basedmypy version

basedmypy 2.5.0 (compiled: yes)

@Loch64 Loch64 added the bug Something isn't working label Aug 1, 2024
@KotlinIsland
Copy link
Owner

KotlinIsland commented Aug 1, 2024

additionally:

def true() -> True: ...
def false() -> False: ...

if bool() and true(): ...
if bool() and false(): ...

#725

@KotlinIsland KotlinIsland changed the title Incorrect redundant-expr error for narrowing constrained TypeVars Incorrect redundant-expr error for isinstance on constrained TypeVars Aug 1, 2024
@Loch64 Loch64 removed their assignment Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants