[docs] Add documentation for typing.Type (issue 27905)
levkivskyi at gmail.com
levkivskyi at gmail.com
Fri Sep 2 16:16:00 EDT 2016
http://bugs.python.org/review/27905/diff/18277/Doc/library/typing.rst
File Doc/library/typing.rst (right):
http://bugs.python.org/review/27905/diff/18277/Doc/library/typing.rst#newcode507
Doc/library/typing.rst:507: A variable of type ``Type[C]`` represents
the class object of some object
I would formulate this a bit longer:
A variable annotated with ``C`` can take values that have type ``C``. In
contrast a variable annotated with ``Type[C]`` can take values that are
classes themselves, namely subclasses of ``C``::
http://bugs.python.org/review/27905/diff/18277/Doc/library/typing.rst#newcode511
Doc/library/typing.rst:511: b = type(a) # Has type 'Type[int]'
I would replace with simply b = int
http://bugs.python.org/review/27905/diff/18277/Doc/library/typing.rst#newcode533
Doc/library/typing.rst:533: It is also legal to use a union of classes
as the parameter to ``Type``::
Maybe it is worth regrouping this to avoid an exception to exception?
For example:
The only legal parameters for ``Type`` are classes, unions of classes,
and ``Any``::
and then after example continue with your text:
``Type[Any]`` is equivalent to ``Type`` which in turn...
http://bugs.python.org/review/27905/
More information about the docs
mailing list