-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Description
Description
Subtypes of UserString
cannot be initialized without a seq
argument as the builtin str
can.
Reproduction
from collections import UserString
class MyString(UserString):
pass
>>> str()
''
>>> MyString()
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
MyString()
~~~~~~~~^^
TypeError: UserString.__init__() missing 1 required positional argument: 'seq'
Workaround
from collections import UserString
class MyString(UserString):
def __init__(self, seq: object = str()) -> None:
super().__init__(seq)
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement