-
Notifications
You must be signed in to change notification settings - Fork 290
Closed
Description
While thinking about protocols, it came to my mind that we could add PathLike to typing, also we could make it a (runtime) protocol class. As I understand PEP 519, it could be typed like this:
S = TypeVar('S', bound=Union[str, bytes])
class PathLike(Generic[S], extra=os.PathLike): # or Protocol[S] in future
def __fspath__(self) -> S:
...So that there will be three allowed types: PathLike[str], PathLike[bytes], and PathLike[Union[str, bytes]]. Or we actually don't need PathLike[Union[str, bytes]]? In this case we could just use AnyStr instead of S.
CC @brettcannon
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels