Don't really understand why you're overriding __new__
. Surely it'd work better to use:
def __init__(self, source: str | Path, *args: Any) -> None:
super().__init__(Path(source, *args).expanduser().resolve())
But this removes self.__source
and the property. I'm not sure what the advantage of using that is but you could always set that before the line super().__init__(Path(source, *args).expanduser().resolve())
.
EDIT: if I've completely misunderstood, please could you explain? I don't really understand what subclassing is trying to achieve here, other than simplifying access to certain os.path
functions.
Glad I could help! I wasn't sure if I was missing something in what you were trying to do - I get that in some cases folding in those features can make things a lot easier.