Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: full typing for "progress" parameter in Repo class #1634

Merged
merged 1 commit into from Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions git/repo/base.py
Expand Up @@ -60,6 +60,7 @@
PathLike,
Lit_config_levels,
Commit_ish,
CallableProgress,
Tree_ish,
assert_never,
)
Expand Down Expand Up @@ -1258,7 +1259,7 @@ def _clone(
def clone(
self,
path: PathLike,
progress: Optional[Callable] = None,
progress: Optional[CallableProgress] = None,
multi_options: Optional[List[str]] = None,
allow_unsafe_protocols: bool = False,
allow_unsafe_options: bool = False,
Expand Down Expand Up @@ -1297,7 +1298,7 @@ def clone_from(
cls,
url: PathLike,
to_path: PathLike,
progress: Optional[Callable] = None,
progress: CallableProgress = None,
env: Optional[Mapping[str, str]] = None,
multi_options: Optional[List[str]] = None,
allow_unsafe_protocols: bool = False,
Expand Down
22 changes: 11 additions & 11 deletions git/types.py
Expand Up @@ -8,42 +8,39 @@
from typing import (
Dict,
NoReturn,
Sequence,
Sequence as Sequence,
Tuple,
Union,
Any,
Optional,
Callable,
TYPE_CHECKING,
TypeVar,
) # noqa: F401

if sys.version_info[:2] >= (3, 8):
if sys.version_info >= (3, 8):
from typing import (
Literal,
SupportsIndex,
TypedDict,
Protocol,
SupportsIndex as SupportsIndex,
runtime_checkable,
) # noqa: F401
else:
from typing_extensions import (
Literal,
SupportsIndex, # noqa: F401
SupportsIndex as SupportsIndex,
TypedDict,
Protocol,
runtime_checkable,
) # noqa: F401

# if sys.version_info[:2] >= (3, 10):
# if sys.version_info >= (3, 10):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a comment that is relevant to the typing system? If not, I think it can be deleted.

# from typing import TypeGuard # noqa: F401
# else:
# from typing_extensions import TypeGuard # noqa: F401


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

if TYPE_CHECKING:
from git.repo import Repo
Expand All @@ -62,6 +59,9 @@

Lit_config_levels = Literal["system", "global", "user", "repository"]

# Progress parameter type alias -----------------------------------------

CallableProgress = Optional[Callable[[int, Union[str, float], Union[str, float, None], str], None]]

# def is_config_level(inp: str) -> TypeGuard[Lit_config_levels]:
# # return inp in get_args(Lit_config_level) # only py >= 3.8
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Expand Up @@ -10,4 +10,4 @@ pytest-icdiff
# pytest-profiling


tox
tox