You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All things type-check and foo has the same type as foo2.
Actual Behavior
main.py:14: note: Revealed type is "def () -> def [T] (def (*Any, **Any) -> T`-1) -> def (*Any, **Any) -> builtins.list[T`-1]"
main.py:15: note: Revealed type is "def [T] (def (*Any, **Any) -> T`-1) -> def (*Any, **Any) -> builtins.list[T`-1]"
main.py:22: note: Revealed type is "builtins.list[builtins.int*]"
main.py:26: note: Revealed type is "def [T] () -> def (def (*Any, **Any) -> T`-1) -> def (*Any, **Any) -> builtins.list[T`-1]"
main.py:27: note: Revealed type is "def (def (*Any, **Any) -> <nothing>) -> def (*Any, **Any) -> builtins.list[<nothing>]"
main.py:29: error: Argument 1 has incompatible type "Callable[[], int]"; expected "Callable[..., <nothing>]"
main.py:34: note: Revealed type is "builtins.list[<nothing>]"
Found 1 error in 1 file (checked 1 source file)
Mypy inferred foo correctly but not foo2. Somehow <nothing> got in where there should be TypeVars. The signatures for to_list and to_list2 are also different and I don't really understand why.
I'm guessing it's because I'm substituting two different TypeVars (T and R) with type expressions that reference the same TypeVarT? But I can't really find a formal definition of how TypeVars work, so I'm not sure if this is supported or not.
Your Environment
Mypy version used: latest
Mypy command-line flags: default
Python version used: 3.10
Operating system and version: mypy-play
The text was updated successfully, but these errors were encountered:
Bug Report
I'm trying to define a generic type alias for a return-type-changing decorator:
So for example, if a decorator wraps a return value in a list, its type could be
Decorator[T, List[T]]
, and it's much clearer than nestedCallable
s.However, this doesn't work. Here's an example (also see on mypy-play):
Expected Behavior
All things type-check and
foo
has the same type asfoo2
.Actual Behavior
Mypy inferred
foo
correctly but notfoo2
. Somehow<nothing>
got in where there should beTypeVar
s. The signatures forto_list
andto_list2
are also different and I don't really understand why.I'm guessing it's because I'm substituting two different
TypeVar
s (T
andR
) with type expressions that reference the sameTypeVar
T
? But I can't really find a formal definition of howTypeVar
s work, so I'm not sure if this is supported or not.Your Environment
The text was updated successfully, but these errors were encountered: