Allow deriving NewType from another unique type (#271)
See discussion in python/mypy#3465
This commit is contained in:
parent
f06c5be3d1
commit
25b7a873f8
|
@ -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::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue