File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -914,6 +914,7 @@ Note that it is legal to use a union of classes as the parameter for
914
914
``Type[]``, as in::
915
915
916
916
def new_non_team_user(user_class: Type[Union[BasicUser, ProUser]]):
917
+ user = new_user(user_class)
917
918
...
918
919
919
920
However the actual argument passed in at runtime must still be a
@@ -952,8 +953,12 @@ attributes and methods defined by ``type`` (for example,
952
953
``__repr__()`` and ``__mro__``). Such a variable can be called with
953
954
arbitrary arguments, and the return type is ``Any``.
954
955
955
- ``Type[T]`` should be considered covariant, since for a concrete class
956
- ``C``, ``Type[C]`` matches ``C`` and any of its subclasses.
956
+ ``Type`` is covariant in its parameter, because ``Type[Derived]`` is a
957
+ subtype of ``Type[Base]``::
958
+
959
+ def new_pro_user(pro_user_class: Type[ProUser]):
960
+ user = new_user(pro_user_class) # OK
961
+ ...
957
962
958
963
959
964
Version and platform checking
You can’t perform that action at this time.
0 commit comments