-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
I am trying to create a typealias for all the types that can be passed as the first argument of open(). MyPy reveals the type to be Union[builtins.str, builtins.bytes, builtins.int, builtins._PathLike[Any]].
My first attempt at this is:
Openable = Union[str, bytes, int, os.PathLike[Any]]MyPy is happy with this, but alas Python is not:
TypeError: 'ABCMeta' object is not subscriptable
Trying this, then:
Openable = Union[str, bytes, int, os.PathLike]But now MyPy is unhappy:
error: Missing type parameters for generic type
What is the correct way of using os.PathLike here? There is no typing.PathLike yet. Do I have to create my own generic version of os.PathLike?
shaunc, hhoppe, glexey and btilongnguyen