Nikita Sobolev <m...@sobolevn.me> added the comment:
> 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46170> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com