-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
In theory, join(a, b)
should always give the same result as join(b, a)
(permutation invariance). However, this is not always the case. One example I found is the following (related to the testAbstractTypeInADict
unit test)
https://mypy-play.net/?mypy=1.17.0&python=3.12&gist=e4df640a72c4f61c1a33a50db60fd6e5
class Class: ...
def join[T](x: T, y: T) -> T: ...
klass: type[Class]
reveal_type(klass) # N: Revealed type is "type[__main__.Class]"
reveal_type(Class) # N: "def () -> __main__.Class"
reveal_type(join(klass, Class)) # N: Revealed type is "builtins.type"
reveal_type(join(Class, klass)) # N: Revealed type is "builtins.object"
Moreover, when debugging this, mypy actually evaluates both is_subtype(left, right)
and is_subtype(right, left)
to true.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong