-
Notifications
You must be signed in to change notification settings - Fork 5
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
Recursive sequence type of Sequence[NotAString]
should not accept str
#819
Comments
oh woops, this should be labeled as bug |
Sequence[NotAString]
should not accept str
feel free to update it 😁 |
is this the same thing? class C[T]: ...
type A = C[A] | int
type B = C[B]
b: B
a: A = b |
If edit |
What's the |
just for being closer to the original egg |
this seems relevant Lines 170 to 189 in 0935784
|
i really don't understand this. if you could put together an egg, that would be good |
how about the egg in the issue itself? |
i don't get that one 😅 probably an egg where it's not using any stdlib, and there is a positive and a negative |
class Increment[T]: # covariant
def current(self, /) -> T: ... # type: ignore[empty-body]
type Infinity = Increment[Infinity]
type Zero = Increment[None]
type Integer = Zero | Increment[Integer]
def int2inf(integer: Integer, /) -> Infinity:
return integer # rejected => ok
def inf2int(infinity: Infinity, /) -> Integer:
return infinity # accepted => wut |
does the covariance impact the situation? is this the same thing? class Thing: ...
class Box[T]: ...
type CouldEnd = Box[CouldEnd] | Thing
type Recursive = Box[Recursive]
b: Recursive = Box()
a: CouldEnd = b # this should be an error
c: CouldEnd = Box[Box[Box[Thing]]]() # this is just for fun |
I thought that both mypy and pyright (incorrectly) inferred |
This is a (p)repost from python#18184, which also applies here:
The false negative can be reproduced with:
mypy-play
alternative example:
The text was updated successfully, but these errors were encountered: