Allow deriving NewType from another unique type (#271)

See discussion in python/mypy#3465
This commit is contained in:
Ivan Levkivskyi 2017-05-30 18:56:56 +02:00 committed by Guido van Rossum
parent f06c5be3d1
commit 25b7a873f8
1 changed files with 3 additions and 2 deletions

View File

@ -1590,8 +1590,9 @@ from ``UserId`` where ``int`` is expected. Examples::
num = UserId(5) + 1 # type: int num = UserId(5) + 1 # type: int
``NewType`` accepts exactly two arguments: a name for the new unique type, ``NewType`` accepts exactly two arguments: a name for the new unique type,
and a base class. The latter should be a proper class, i.e., and a base class. The latter should be a proper class (i.e.,
not a type construct like ``Union``, etc. The function returned by ``NewType`` not a type construct like ``Union``, etc.), or another unique type created
by calling ``NewType``. The function returned by ``NewType``
accepts only one argument; this is equivalent to supporting only one accepts only one argument; this is equivalent to supporting only one
constructor accepting an instance of the base class (see above). Example:: constructor accepting an instance of the base class (see above). Example::