[issue43413] tuple subclasses allow arbitrary kwargs

Jason R. Coombs report at bugs.python.org
Fri Sep 17 09:53:47 EDT 2021


Jason R. Coombs <jaraco at jaraco.com> added the comment:

>> Subclass of set can now define
> Is there any use case for this?

Is your concern about a use-case for the general concept or for set specifically?

I appreciate that Serhiy has taken the time to evaluate the specific concern I raised and extrapolate it to the implications for most/all built-in types. It seems worthwhile to me that built-in types have consistent behaviors. Moreover, it seems preferable to provide the intuitive behavior (allowing simply overriding `__new__`) without the baggage of needing to define `__init__`. I'd not be surprised if there was a real-world use-case in which `set.__new__` was overridden in a subclass and the user was forced to add an `__init__` just to bypass "set() takes no keyword arguments". Interestingly, searching the web for that exact error doesn't emit any results, so if someone has encountered it, it wasn't posted with the error message.

After exploring this some, I'm convinced there may not be a strong case for this behavior.

Raymond, if this new behavior was removed, how would you propose to rewrite the test (specifically https://github.com/python/cpython/blob/778b07565e38cc94aa90318eb47b9cd09716756a/Lib/test/test_set.py#L665-L673)?

----------

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


More information about the Python-bugs-list mailing list