[New-bugs-announce] [issue46170] Improving the error message when subclassing NewType

Gobot1234 report at bugs.python.org
Thu Dec 23 19:01:32 EST 2021


New submission from Gobot1234 <gobot1234yt at gmail.com>:

I'd like to propose making the error message when subclassing typing.NewType much more understandable. Currently it looks like:
```
TypeError: NewType.__init__() takes 3 positional arguments but 4 were given
```
But I think we could do much better by adding __mro_entries__ to the class and then just having that raise a TypeError telling users they cannot subclass NewType and they are probably looking for `NewType('Subclass', OlderType)`. I'd be happy to patch this myself if this sounds like a good idea.

----------
components: Library (Lib)
messages: 409114
nosy: Gobot1234, gvanrossum, kj
priority: normal
severity: normal
status: open
title: Improving the error message when subclassing NewType
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46170>
_______________________________________


More information about the New-bugs-announce mailing list