-
Notifications
You must be signed in to change notification settings - Fork 581
Open
Description
When __new__ is overridden, the return type should be Self, or just left empty for the type checker to infer. Currently some of these are hardcoded to the class name:
Line 306 in 9f76b0f
| def __new__(cls, value: str, base: str | None = None) -> URIRef: |
The issue with this is that any child class UriSubclass that tries to inherit from it and call super().__new__() will think it has an instance of UriSubclass and not Child:
class UriSubclass(URIRef):
def __new__(cls, value: str, base: str | None = None) -> Self:
return super().__new__(cls, value, base)Gives:
Type "URIRef" is not assignable to return type "Self@UriSubclass"
Metadata
Metadata
Assignees
Labels
No labels