[docs] Expand documentation about type aliases and NewType in the typing module (issue 27644)

guido at python.org guido at python.org
Thu Jul 28 17:49:09 EDT 2016


Great! A few nits.


http://bugs.python.org/review/27644/diff/18004/Doc/library/typing.rst
File Doc/library/typing.rst (right):

http://bugs.python.org/review/27644/diff/18004/Doc/library/typing.rst#newcode32
Doc/library/typing.rst:32: A type alias is defined by assigning the type
to the alias. In this example,
Can you try to make all lines you've added shorter than 80 chars? Even
the examples (examples with long lines cause annoying horizontal scroll
bars).

http://bugs.python.org/review/27644/diff/18004/Doc/library/typing.rst#newcode36
Doc/library/typing.rst:36: Vector = List[float]
I'd add an example that passes a List[float] into a function expecting a
Vector. E.g.

def sum(a: Vector): ...
sum([0.0, 1.1, 2.2])

http://bugs.python.org/review/27644/diff/18004/Doc/library/typing.rst#newcode92
Doc/library/typing.rst:92: Recall that type aliases declares two types
to be *equivalent* to one another.
"type aliases declares" -- plural subject with singular verb. Maybe "the
use of a type alias causes two types ..." ?

http://bugs.python.org/review/27644/diff/18004/Doc/library/typing.rst#newcode97
Doc/library/typing.rst:97: In contrast, ``NewType`` declares one type to
be a *derivative* of another.
derivative -> subtype

http://bugs.python.org/review/27644/


More information about the docs mailing list