@@ -1019,6 +1019,33 @@ the other hand, when a value has type ``Any``, the type checker will
1019
1019
allow all operations on it, and a value of type ``Any`` can be assigned
1020
1020
to a variable (or used as a return value) of a more constrained type.
1021
1021
1022
+ A function parameter without an annotation is assumed to be annotated with
1023
+ ``Any``. If a gneric type is used without specifying type parameters,
1024
+ they assumed to be ``Any``::
1025
+
1026
+ from typing import Mapping
1027
+
1028
+ def use_map(m: Mapping) -> None: # Same as Mapping[Any, Any]
1029
+ ...
1030
+
1031
+ This rule also applies to ``Tuple``, in annotation context it is equivalent
1032
+ to ``Tuple[Any, ...]`` and, in turn, to ``tuple``. As well, a bare
1033
+ ``Callable`` in an annotation is equivalent to ``Callable[[...], Any]`` and,
1034
+ in turn, to ``collections.abc.Callable``::
1035
+
1036
+ from typing import Tuple, List, Callable
1037
+
1038
+ def check_args(args: Tuple) -> bool:
1039
+ ...
1040
+
1041
+ check_args(()) # OK
1042
+ check_args((42, 'abc')) # Also OK
1043
+ check_args(3.14) # Flagged as error by a type checker
1044
+
1045
+ # A list of arbitrary callables is accepted by this function
1046
+ def apply_callbacks(cbs: List[Callable]) -> None:
1047
+ ...
1048
+
1022
1049
1023
1050
The type of class objects
1024
1051
-------------------------
0 commit comments