[issue33170] New type based on int() created with typing.NewType is not consistent
New submission from Maxim Avanov : >From my understanding of the docs section on new types, >https://docs.python.org/3/library/typing.html#newtype the new type based on int() should just pass the value into the base constructor. However, ``` PercentDiscount = NewType('PercentDiscount', int) >>> PercentDiscount(50) == int(50) True >>> int('50') == int(50) True >>> PercentDiscount('50') == PercentDiscount(50) False ``` -- components: Library (Lib) messages: 314598 nosy: avanov priority: normal severity: normal status: open title: New type based on int() created with typing.NewType is not consistent versions: Python 3.6 ___ Python tracker <https://bugs.python.org/issue33170> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33170] New type based on int() created with typing.NewType is not consistent
Maxim Avanov added the comment: Logically, I would expect it to behave similarly to ``` >>> class PercentDiscount(int): pass >>> PercentDiscount('50') == PercentDiscount(50) True ``` -- ___ Python tracker <https://bugs.python.org/issue33170> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33170] New type based on int() created with typing.NewType is not consistent
Maxim Avanov added the comment: Ok, after further reading, I see that NewType creates an identity stub. -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue33170> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com