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
{{ message }}
Repository navigation
Version 0.780 does not recognize python internal types as typing.Type anymore #8992
The same happens with Optional[str] etc.. If Type is not the correct type to use, what should be used instead? How should I annotate mapping in this example?:
@JukkaL That's not really satisfying isn't it? I would like to use something that expresses that the values in the mapping are type-like, not instances. Using Any or object is basically saying "I don't care about the type". I want mypy to warn that any of the following entries are not allowed:
Activity
ilevkivskyi commentedon Jun 12, 2020
This is intended, at runtime
Union[int, str]is not a subclass oftype(on most newer version of Python anymore).aachurin commentedon Jun 16, 2020
But the documentation says the following:
The only legal parameters for Type are classes, Any, type variables, and unions of any of these types. For example:
def new_non_team_user(user_class: Type[Union[BaseUser, ProUser]]): ...Type[Any] is equivalent to Type which in turn is equivalent to type, which is the root of Python’s metaclass hierarchy.
hmvp commentedon Jun 17, 2020
The same happens with
Optional[str]etc.. IfTypeis not the correct type to use, what should be used instead? How should I annotatemappingin this example?:JukkaL commentedon Jun 19, 2020
@hmvp You need to use
objectorAny.hmvp commentedon Jun 22, 2020
@JukkaL That's not really satisfying isn't it? I would like to use something that expresses that the values in the mapping are type-like, not instances. Using
Anyorobjectis basically saying "I don't care about the type". I want mypy to warn that any of the following entries are not allowed: