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

(🐞) type[T] can't be assigned to Protocol with __name__ #17470

Open
KotlinIsland opened this issue Jul 3, 2024 · 0 comments
Open

(🐞) type[T] can't be assigned to Protocol with __name__ #17470

KotlinIsland opened this issue Jul 3, 2024 · 0 comments
Labels
bug mypy got something wrong

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Jul 3, 2024

from typing import Protocol

class HasName(Protocol):
    __name__: str

class A: ...

t: type[A] = A
n: HasName 
n = A  # no error
n = t  # error: Incompatible types in assignment (expression has type "type[A]", variable has type "HasName")  [assignment]
@KotlinIsland KotlinIsland added the bug mypy got something wrong label Jul 3, 2024
@KotlinIsland KotlinIsland changed the title (🐞) type[T] can't be assigned to protocol with __name__ when passed through (🐞) type[T] can't be assigned to protocol with __name__ Jul 3, 2024
@KotlinIsland KotlinIsland changed the title (🐞) type[T] can't be assigned to protocol with __name__ (🐞) type[T] can't be assigned to Protocol with __name__ Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant