-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
The pathlib implementation seems to go to some trouble to preserve subtypes in children. This works fine:
import pathlib
class MyPath(pathlib.PosixPath):
def parity(self):
return len(str(self)) % 2
root = MyPath('/')
print(root.parity())
child = root / 'there'
print(child.parity())$ python3 t.py
1
0
But this declaration isn't parameterized:
def __truediv__(self, key: Union[str, PurePath]) -> PurePath: ...so the program above doesn't typecheck:
$ mypy t.py
t.py:11: error: "PurePath" has no attribute "parity"
Metadata
Metadata
Assignees
Labels
No labels