@@ -3246,14 +3246,15 @@ class B: ...
32463246
32473247T = TypeVar("T")
32483248
3249- def forgets_about_subclasses1 (self, obj: T) -> T:
3249+ def forgets_about_subclasses (self, obj: T) -> T:
32503250 if isinstance(obj, A):
32513251 return A() # E: Incompatible return value type (got "A", expected "T")
32523252 elif isinstance(obj, B):
32533253 return B() # E: Incompatible return value type (got "B", expected "T")
32543254 raise
32553255
32563256def correct1(self, obj: T) -> T:
3257+ # TODO: mypy should not error in this case
32573258 if type(obj) == A:
32583259 return A() # E: Incompatible return value type (got "A", expected "T")
32593260 elif type(obj) == B:
@@ -3262,7 +3263,10 @@ def correct1(self, obj: T) -> T:
32623263
32633264T_value = TypeVar("T_value", A, B)
32643265
3265- def forgets_about_subclasses2(self, obj: T_value) -> T_value:
3266+ def forgets_about_multiple_inheritance(self, obj: T_value) -> T_value:
3267+ # Note that it is a little confusing that mypy only errors in the first branch here, but this
3268+ # is a branch that would be taken by a subclass of both A and B.
3269+ # See also https://github.com/python/mypy/issues/10302#issuecomment-3832182574
32663270 if isinstance(obj, A):
32673271 return A() # E: Incompatible return value type (got "A", expected "B")
32683272 elif isinstance(obj, B):
@@ -3485,6 +3489,7 @@ from typing import TypeVar, Any, Type
34853489
34863490TargetType = TypeVar("TargetType", int, float, str)
34873491
3492+ # TODO: this behaviour is incorrect, it will be fixed by improving reachability
34883493def convert_type(target_type: Type[TargetType]) -> TargetType:
34893494 if target_type == str:
34903495 return str() # E: Incompatible return value type (got "str", expected "int") \
@@ -3503,6 +3508,7 @@ def convert_type(target_type: Type[TargetType]) -> TargetType:
35033508from __future__ import annotations
35043509from typing import Literal
35053510
3511+ # TODO: the behaviour on some of these test cases is incorrect
35063512def f1(number: float, i: int):
35073513 if number == i:
35083514 reveal_type(number) # N: Revealed type is "builtins.float"
0 commit comments