From 475a7e1d5a311310f70f155d0e57decd7290aba5 Mon Sep 17 00:00:00 2001 From: Predeactor Date: Sun, 31 Jul 2022 21:58:46 +0200 Subject: [PATCH 1/4] Fix typehinting for PathLike --- git/types.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/git/types.py b/git/types.py index a4e839ba6..adda514da 100644 --- a/git/types.py +++ b/git/types.py @@ -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, @@ -30,7 +26,6 @@ ) # noqa: F401 else: from typing_extensions import ( - Final, Literal, SupportsIndex, # noqa: F401 TypedDict, @@ -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 @@ -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): From e176e54091f39fd4d1d75ebbfa3d8f3ef8191262 Mon Sep 17 00:00:00 2001 From: Predeactor Date: Sun, 31 Jul 2022 21:59:24 +0200 Subject: [PATCH 2/4] Add contributor to AUTHORS file --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 546818f5f..2ac02e5fb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -46,4 +46,5 @@ Contributors are: -Robert Westman -Hugo van Kemenade -Hiroki Tokunaga +-Julien Mauroy Portions derived from other open source works and are clearly marked. From 4236b290ddc2eb224f9ff834a21b373015aad782 Mon Sep 17 00:00:00 2001 From: Predeactor Date: Sun, 7 Aug 2022 18:31:03 +0200 Subject: [PATCH 3/4] fix: remove bytes type of PathLike Signed-off-by: Predeactor --- git/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/types.py b/git/types.py index adda514da..da938c303 100644 --- a/git/types.py +++ b/git/types.py @@ -40,7 +40,7 @@ if sys.version_info[:2] < (3, 9): - PathLike = Union[str, bytes, os.PathLike] + PathLike = Union[str, os.PathLike[str]] else: # os.PathLike only becomes subscriptable from Python 3.9 onwards PathLike = Union[str, bytes, os.PathLike[str], os.PathLike[bytes]] From 2303971c73f4ceda1d2d50e55a7c9d99864b883e Mon Sep 17 00:00:00 2001 From: Predeactor Date: Sun, 7 Aug 2022 18:32:57 +0200 Subject: [PATCH 4/4] fix: incorrect PathLike corrected Signed-off-by: Predeactor --- git/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git/types.py b/git/types.py index da938c303..9064ecbf9 100644 --- a/git/types.py +++ b/git/types.py @@ -40,10 +40,10 @@ if sys.version_info[:2] < (3, 9): - PathLike = Union[str, os.PathLike[str]] + PathLike = Union[str, os.PathLike] else: # os.PathLike only becomes subscriptable from Python 3.9 onwards - PathLike = Union[str, bytes, os.PathLike[str], os.PathLike[bytes]] + PathLike = Union[str, os.PathLike[str]] if TYPE_CHECKING: from git.repo import Repo