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

Revise type annotations slightly #1860

Merged
merged 3 commits into from
Mar 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ class CatFileContentStream:
rest to ensure the underlying stream continues to work.
"""

__slots__: Tuple[str, ...] = ("_stream", "_nbr", "_size")
__slots__ = ("_stream", "_nbr", "_size")

def __init__(self, size: int, stream: IO[bytes]) -> None:
self._stream = stream
Expand Down Expand Up @@ -846,14 +846,14 @@ def __del__(self) -> None:
self._stream.read(bytes_left + 1)
# END handle incomplete read

def __init__(self, working_dir: Union[None, PathLike] = None):
def __init__(self, working_dir: Union[None, PathLike] = None) -> None:
"""Initialize this instance with:

:param working_dir:
Git directory we should work in. If ``None``, we always work in the current
directory as returned by :func:`os.getcwd`.
This is meant to be the working tree directory if available, or the
``.git`` directory in case of bare repositories.
Git directory we should work in. If ``None``, we always work in the current
directory as returned by :func:`os.getcwd`.
This is meant to be the working tree directory if available, or the
``.git`` directory in case of bare repositories.
"""
super().__init__()
self._working_dir = expand_path(working_dir)
Expand Down Expand Up @@ -1103,8 +1103,8 @@ def execute(
:raise git.exc.GitCommandError:

:note:
If you add additional keyword arguments to the signature of this method,
you must update the ``execute_kwargs`` variable housed in this module.
If you add additional keyword arguments to the signature of this method, you
must update the ``execute_kwargs`` variable housed in this module.
"""
# Remove password for the command if present.
redacted_command = remove_password_if_present(command)
Expand Down Expand Up @@ -1438,7 +1438,7 @@ def _call_process(

turns into::

git rev-list max-count 10 --header master
git rev-list max-count 10 --header master

:return:
Same as :meth:`execute`. If no args are given, used :meth:`execute`'s
Expand Down
2 changes: 1 addition & 1 deletion git/objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Object(LazyMixin):

type: Union[Lit_commit_ish, None] = None

def __init__(self, repo: "Repo", binsha: bytes):
def __init__(self, repo: "Repo", binsha: bytes) -> None:
"""Initialize an object by identifying it by its binary sha.

All keyword arguments will be set on demand if ``None``.
Expand Down
2 changes: 1 addition & 1 deletion git/objects/submodule/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RootModule(Submodule):

k_root_name = "__ROOT__"

def __init__(self, repo: "Repo"):
def __init__(self, repo: "Repo") -> None:
# repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None)
super().__init__(
repo,
Expand Down
2 changes: 1 addition & 1 deletion git/refs/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class HEAD(SymbolicReference):

__slots__ = ()

def __init__(self, repo: "Repo", path: PathLike = _HEAD_NAME):
def __init__(self, repo: "Repo", path: PathLike = _HEAD_NAME) -> None:
if path != self._HEAD_NAME:
raise ValueError("HEAD instance must point to %r, got %r" % (self._HEAD_NAME, path))
super().__init__(repo, path)
Expand Down
2 changes: 1 addition & 1 deletion git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def __new__(cls, filepath: Union[PathLike, None] = None) -> "RefLog":
inst = super().__new__(cls)
return inst

def __init__(self, filepath: Union[PathLike, None] = None):
def __init__(self, filepath: Union[PathLike, None] = None) -> None:
"""Initialize this instance with an optional filepath, from which we will
initialize our data. The path is also used to write changes back using the
:meth:`write` method."""
Expand Down
2 changes: 1 addition & 1 deletion git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SymbolicReference:
_remote_common_path_default = "refs/remotes"
_id_attribute_ = "name"

def __init__(self, repo: "Repo", path: PathLike, check_path: bool = False):
def __init__(self, repo: "Repo", path: PathLike, check_path: bool = False) -> None:
self.repo = repo
self.path = path

Expand Down
2 changes: 1 addition & 1 deletion git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ class Stats:

__slots__ = ("total", "files")

def __init__(self, total: Total_TD, files: Dict[PathLike, Files_TD]):
def __init__(self, total: Total_TD, files: Dict[PathLike, Files_TD]) -> None:
self.total = total
self.files = files

Expand Down
Loading