Be careful with annotations and typing. The ideas discussed in 484 are new and implemented in the typing
module. This module is only available in Python3.5 (the latest typing
also available from pip
for Py2 and Py3).
https://docs.python.org/3/library/typing.html
This is the note that you indicated from section 484, which begins:
To open the use of static type checking in Python 3.5, as well as older versions, a uniform namespace is required. To this end, a new module is introduced in the standard library, called typing.
That in the lists of notes there are types of annotations, and not the actual classes of objects (built-in or from collections
). Do not confuse them.
Note that Dict
, List
, Set
and FrozenSet
all uppercase letters, where the functions (and type names) are Dict
, List
, Set
, FrozenSet
. In other words, to make a dictionary, you use dict()
or {}
, not Dict
.
Annotations are new to 3.0 (not at 2.n at all). In the regular interpreter, all they do is populate the __annotations__
dictionary. There are no or no comments in the interpreter.
http://mypy-lang.org/ describes itself as an experimental input check. You need to look at the documentation to see how compatible it is with 484, etc.
https://docs.python.org/3/library/collections.abc.html#module-collections.abc contains some abstract definitions that I believe are used by typing
. I have never used them. They are mainly intended for people developing new classes of objects, rather than "ordinary" users.
The typing
tag for this question is probably not a good idea. He has few followers and is too general. It does not apply to this Python module.
Find [python] 484
for other SO questions regarding this annotation style.
https://github.com/python/typing - typing
development repository.
There is a FrozenSet
definition in this repository in the python2/typing.py
(python2 backport) file, but not in src/typing.py
. I am not sure of the meaning of this.