Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix typehinting for PathLike
  • Loading branch information
Predeactor committed Jul 31, 2022
commit 475a7e1d5a311310f70f155d0e57decd7290aba5
13 changes: 3 additions & 10 deletions git/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@
import os
import sys
from typing import (
Callable,
Dict,
NoReturn,
Sequence,
Tuple,
Union,
Any,
Iterator, # noqa: F401
NamedTuple,
TYPE_CHECKING,
TypeVar,
) # noqa: F401

if sys.version_info[:2] >= (3, 8):
from typing import (
Final,
Literal,
SupportsIndex,
TypedDict,
Expand All @@ -30,7 +26,6 @@
) # noqa: F401
else:
from typing_extensions import (
Final,
Literal,
SupportsIndex, # noqa: F401
TypedDict,
Expand All @@ -45,10 +40,10 @@


if sys.version_info[:2] < (3, 9):
PathLike = Union[str, os.PathLike]
elif sys.version_info[:2] >= (3, 9):
PathLike = Union[str, bytes, os.PathLike]
else:
# os.PathLike only becomes subscriptable from Python 3.9 onwards
PathLike = Union[str, os.PathLike]
PathLike = Union[str, bytes, os.PathLike[str], os.PathLike[bytes]]

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -92,8 +87,6 @@ def assert_never(inp: NoReturn, raise_error: bool = True, exc: Union[Exception,
raise ValueError(f"An unhandled Literal ({inp}) in an if/else chain was found")
else:
raise exc
else:
pass


class Files_TD(TypedDict):
Expand Down