Replies: 2 comments 4 replies
-
I'm guessing because use of the type alias from outside the class would not make sense. As a workaround, you could define a generic type alias and then bind that generic type alias to the type variable. Edit: this has the somewhat nice property of making explicit what parts of method signatures are generic (I was curious, looks like mypy and pyright match behaviour here) |
Beta Was this translation helpful? Give feedback.
-
@ntessore can you post your solution here? I am also running into this issue. My solution here is to use a classproperty decorator to store the union in a method return type.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I don't quite follow why the following situation is not supported:
Simply writing out the alias works fine, of course:
In particular, could someone point me to a reference that explains why I
because, in my understanding, the fact that
T
is a bound type variable means precisely that I am not defining a generic alias here.Edit: For what it's worth, I just saw that the error was introduced in python/mypy#4000 because this is an "ambiguous" situation without further specifying the ambiguity.
Beta Was this translation helpful? Give feedback.
All reactions