This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sobolevn
Recipients AlexWaygood, Gobot1234, gvanrossum, kj, sobolevn
Date 2021-12-26.17:29:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1640539767.11.0.315645537274.issue46170@roundup.psfhosted.org>
In-reply-to
Content
> So maybe those docs are incorrect? I can't find anything in PEP 484 about this.

Mypy even has an explicit test that NewType of NewType should work: https://github.com/python/mypy/blob/f96446ce2f99a86210b21d39c7aec4b13a8bfc66/test-data/unit/check-newtype.test#L162-L165

I tend to agree with this behavior. This allows us to create complex type-safe DSLs:

```python
from typing import NewType

UserId = NewType('UserId', int)
ProUserId = NewType('ProUserId', UserId)

x: ProUserId = ProUserId(UserId(1))
```

Mypy is happy with that!

I will open a new issue about incorrect docs.
History
Date User Action Args
2021-12-26 17:29:27sobolevnsetrecipients: + sobolevn, gvanrossum, Gobot1234, kj, AlexWaygood
2021-12-26 17:29:27sobolevnsetmessageid: <1640539767.11.0.315645537274.issue46170@roundup.psfhosted.org>
2021-12-26 17:29:27sobolevnlinkissue46170 messages
2021-12-26 17:29:27sobolevncreate