Skip to content

Commit 05ad123

Browse files
committed
Alter non-type-checking typings to have PathLike appear as a link to the standard-library's os.PathLike instead of the workaround replacement defined in ipfshttpclient/utils.py
1 parent 0094be0 commit 05ad123

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

ipfshttpclient/utils.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,22 @@ class Protocol:
2828
Literal_True = Literal_False = bool
2929

3030
if sys.version_info >= (3, 6): #PY36+
31+
# `os.PathLike` only has a type param while type checking
3132
if ty.TYPE_CHECKING:
32-
PathLike = os.PathLike # This has a type param only while type checking
33+
PathLike = os.PathLike
34+
PathLike_str = os.PathLike[str]
35+
PathLike_bytes = os.PathLike[bytes]
3336
else:
3437
class PathLike(Protocol, ty.Generic[ty.AnyStr]):
3538
def __fspath__(self) -> ty.AnyStr:
3639
...
40+
41+
PathLike_str = PathLike_bytes = os.PathLike
3742

38-
path_str_t = ty.Union[str, PathLike[str]]
39-
path_bytes_t = ty.Union[bytes, PathLike[bytes]]
43+
path_str_t = ty.Union[str, PathLike_str]
44+
path_bytes_t = ty.Union[bytes, PathLike_bytes]
4045
path_t = ty.Union[path_str_t, path_bytes_t]
41-
AnyPath = ty.TypeVar("AnyPath", str, PathLike[str], bytes, PathLike[bytes])
46+
AnyPath = ty.TypeVar("AnyPath", str, PathLike_str, bytes, PathLike_bytes)
4247

4348
path_types = (str, bytes, os.PathLike,)
4449
path_obj_types = (os.PathLike,)
@@ -48,11 +53,11 @@ def convert_path(path: ty.AnyStr) -> ty.AnyStr:
4853
...
4954

5055
@ty.overload
51-
def convert_path(path: PathLike[str]) -> PathLike[str]:
56+
def convert_path(path: PathLike_str) -> PathLike_str:
5257
...
5358

5459
@ty.overload
55-
def convert_path(path: PathLike[bytes]) -> PathLike[bytes]:
60+
def convert_path(path: PathLike_bytes) -> PathLike_bytes:
5661
...
5762

5863
@ty.overload

0 commit comments

Comments
 (0)