I want to define a NewType like this:
from typing import NewType
from os import PathLike
AnyPath = PathLike[str] | str
RepoPath = NewType("RepoPath", AnyPath) # ERR: Argument 2 to NewType(...) must be subclassable (got "Union[PathLike[str], str]")
# RepoPath = NewType("RepoPath", PathLike[str]) # ERR: NewType cannot be used with protocol classes
Basically so that later I can pass a raw path "str" or a "pathlib.Path" to functions, and they can enforce this is specifically a path to a "Repo" rather than a random path. This is useful because there are a lot of paths and urls etc in my code and I don't want them to get mixed up (I don't want to use (Apps) hungarian notation especially either).
Is there a good way to get the type checker to do this for me?