Skip to content

Add types to refs #1295

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

Merged
merged 22 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
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
update types in types.py
  • Loading branch information
Yobmod committed Jul 19, 2021
commit 2fa9fb1ac11b53859959ea9bd37c0ae6c17ccdb5
7 changes: 4 additions & 3 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def write_tree(self) -> Tree:
# note: additional deserialization could be saved if write_tree_from_cache
# would return sorted tree entries
root_tree = Tree(self.repo, binsha, path='')
root_tree._cache = tree_items # type: ignore # should this be encoded to [bytes, int, str]?
root_tree._cache = tree_items
return root_tree

def _process_diff_args(self, # type: ignore[override]
Expand All @@ -586,8 +586,9 @@ def _process_diff_args(self, # type: ignore[override]
return args

def _to_relative_path(self, path: PathLike) -> PathLike:
""":return: Version of path relative to our git directory or raise ValueError
if it is not within our git direcotory"""
"""
:return: Version of path relative to our git directory or raise ValueError
if it is not within our git direcotory"""
if not osp.isabs(path):
return path
if self.repo.bare:
Expand Down
5 changes: 2 additions & 3 deletions git/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from typing import (Callable, Dict, NoReturn, Sequence, Tuple, Union, Any, Iterator, # noqa: F401
NamedTuple, TYPE_CHECKING, TypeVar) # noqa: F401

if TYPE_CHECKING:
from git.repo import Repo

if sys.version_info[:2] >= (3, 8):
from typing import Final, Literal, SupportsIndex, TypedDict, Protocol, runtime_checkable # noqa: F401
else:
Expand All @@ -28,6 +25,7 @@
PathLike = Union[str, 'os.PathLike[str]'] # forward ref as pylance complains unless editing with py3.9+

if TYPE_CHECKING:
from git.repo import Repo
from git.objects import Commit, Tree, TagObject, Blob
# from git.refs import SymbolicReference

Expand All @@ -36,6 +34,7 @@

Tree_ish = Union['Commit', 'Tree']
Commit_ish = Union['Commit', 'TagObject', 'Blob', 'Tree']
Lit_commit_ish = Literal['commit', 'tag', 'blob', 'tree']

# Config_levels ---------------------------------------------------------

Expand Down