Skip to content

Improve static typing and docstrings related to git object types #1859

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 82 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
f83b056
Revise assert_never
EliahKagan Mar 2, 2024
01cc8e2
Fix unnecessarily long reference in Tree docstrings
EliahKagan Mar 3, 2024
6f3a20f
Change how tree[subscript] is introduced
EliahKagan Mar 3, 2024
85889cd
Refine how tree[subscript] is introduced
EliahKagan Mar 3, 2024
9e47083
Start adding docstrings to types in git.types
EliahKagan Mar 3, 2024
3bd8177
Document Tree_ish, Commit_ish, and related types
EliahKagan Mar 3, 2024
f3b9a69
Expand docs of classes representing Git objects
EliahKagan Mar 3, 2024
2af7640
Do a bit of tidying related to unused names
EliahKagan Mar 3, 2024
2aa053e
Add docstrings to TypedDicts in git.types
EliahKagan Mar 3, 2024
15d50de
Revise a couple new docstrings for clarity
EliahKagan Mar 4, 2024
7166703
Fix possible inaccuracy in Lit_config_levels docstring
EliahKagan Mar 4, 2024
1530fd2
Use phrases like "git object type" where applicable
EliahKagan Mar 4, 2024
2e02b09
Add docstrings to protocols in git.types
EliahKagan Mar 4, 2024
012d710
Move our PathLike below even TYPE_CHECKING imports
EliahKagan Mar 4, 2024
a06f1fc
Remove commented-out is_config_level function
EliahKagan Mar 4, 2024
c93e431
Expand git.compat docstring
EliahKagan Mar 4, 2024
29443ce
Add a cationary note about Object vs. object
EliahKagan Mar 4, 2024
b6e3ad2
Don't bind unused _assertion_msg_format
EliahKagan Mar 4, 2024
b5d9198
Remove commented-out code
EliahKagan Mar 6, 2024
2212ac9
Fix Sphinx reference that rendered overly long
EliahKagan Mar 7, 2024
3c5ca52
Simplify _safer_popen_windows "if shell" logic
EliahKagan Mar 7, 2024
43b7f8a
Annotate safer_popen broad enough for all platforms
EliahKagan Mar 7, 2024
dc95a76
Fix mypy error with creationflags in subprocess module
EliahKagan Mar 7, 2024
4191f7d
Refactor kill_after_timeout logic so mypy can check it
EliahKagan Mar 7, 2024
1ef3365
Factor communicate and watchdog logic to helper
EliahKagan Mar 7, 2024
4083dd8
Fix new mypy confusion about kill_after_timeout type
EliahKagan Mar 7, 2024
3aeef46
Fix how Diffable annotates expected repo attribute
EliahKagan Mar 7, 2024
f1cc1fe
Fix how HEAD annotates inherited commit property
EliahKagan Mar 8, 2024
e133018
Broaden cygpath parameter annotation
EliahKagan Mar 8, 2024
c34a466
Have Repo.__init__ convert epath to str first instead
EliahKagan Mar 8, 2024
4dfd480
Fix how Remote annotates dynamic config-backed url attribute
EliahKagan Mar 8, 2024
e4fd2e3
Drop wrong variable annotations in BlobFilter.__call__
EliahKagan Mar 8, 2024
94344b4
Clarify CallableProgress vs. CallableRemoteProgress
EliahKagan Mar 8, 2024
8e8b87a
Fix RootModule.update `ignore[override]` suppression
EliahKagan Mar 8, 2024
1cdec7a
Fix wrong class name in git.objects.tag docstring
EliahKagan Mar 8, 2024
ed6ead9
Correct and clarify Diffable.diff docstring
EliahKagan Mar 8, 2024
0e1df29
Start fixing diff and _process_diff_args type annotations
EliahKagan Mar 9, 2024
62c0823
Consolidate str and os.PathLike[str] (use GitPython's PathLike)
EliahKagan Mar 9, 2024
7204cc1
Further clarify Diffable.diff docstring
EliahKagan Mar 9, 2024
2f5e258
Annotate _process_diff_args without Diffable.Index
EliahKagan Mar 9, 2024
65863a2
Make NULL_TREE and Index precisely annotatable
EliahKagan Mar 9, 2024
c9952e1
Fix Sphinx references; give Diffable.Index a docstring
EliahKagan Mar 9, 2024
b8a25df
Modify annotations to accommodate NULL_TREE
EliahKagan Mar 9, 2024
e49327d
Add refresh to top-level __all__
EliahKagan Feb 24, 2024
c8ad3a3
Deprecate public access to typing imports in git
EliahKagan Feb 24, 2024
3c8cbe9
Mention collections.abc for Sequence
EliahKagan Mar 5, 2024
87b314e
Add INDEX and DiffConstants to git.__all__
EliahKagan Mar 9, 2024
9ed904c
Adjust mypy options to work well with mypy 1.9.0
EliahKagan Mar 9, 2024
aeacb00
Colorize mypy output on CI for easier reading
EliahKagan Mar 9, 2024
84fc806
Remove some unneeded mypy suppressions
EliahKagan Mar 10, 2024
96ecc2e
Drop deprecated mypy option
EliahKagan Mar 10, 2024
97d9b65
Apply intended suppression in Tree.traverse
EliahKagan Mar 10, 2024
ad00c77
Spell self.Index as self.INDEX in IndexFile.diff
EliahKagan Mar 10, 2024
2decbe4
Test that redefined Diffable.Index should be compatible
EliahKagan Mar 10, 2024
88557bc
Have git module use sys.platform to check for Windows
EliahKagan Mar 10, 2024
7204c13
Fix new mypy error in _read_win_env_flag
EliahKagan Mar 10, 2024
42e10c0
Fix new mypy error in is_cygwin_git
EliahKagan Mar 10, 2024
465ab56
Have test suite use sys.platform to check for Windows
EliahKagan Mar 10, 2024
ad8190b
Wrap docstrings and comments in _safer_popen_windows
EliahKagan Mar 10, 2024
b9d9e56
Further improve _safer_popen_windows doc
EliahKagan Mar 10, 2024
04a2753
Temporarily rename Commit_ish to Old_commit_ish
EliahKagan Mar 10, 2024
787f65c
Define and document AnyGitObject and (new) Commit_ish
EliahKagan Mar 10, 2024
1fe4dc8
Define GitObjectTypeString and update Object to use it
EliahKagan Mar 10, 2024
7328a00
Start fixing annotations that used the old Commit_ish
EliahKagan Mar 10, 2024
191f4cf
Fix some annotations in git.repo.fun
EliahKagan Mar 10, 2024
d1ce940
Remove extra `parents` param in Commit.__init__ docstring
EliahKagan Mar 10, 2024
fe42ca7
Help tools know the type of a Commit's `parents`
EliahKagan Mar 11, 2024
e66297a
Keep the type of a Commit's `parents` from being too narrow
EliahKagan Mar 11, 2024
fe7f9f2
Fix remaining old Commit_ish annotations in git.repo.fun
EliahKagan Mar 11, 2024
ab27827
Fix remaining old Commit_ish annotations in git.refs
EliahKagan Mar 11, 2024
b4b6e1e
Fix IndexFile.commit `parent_commits` annotation
EliahKagan Mar 11, 2024
5b2869f
Fix old Commit_ish annotations in git.remote
EliahKagan Mar 11, 2024
1541c62
Start on fixing Submodule parent_commit annotations
EliahKagan Mar 11, 2024
1f03e7f
Fix other submodule.base parent_commit annotations
EliahKagan Mar 14, 2024
e66b8f1
Fix old Commit_ish annotation in RootModule
EliahKagan Mar 14, 2024
93d19dc
Remove the temporary Old_commit_ish type
EliahKagan Mar 14, 2024
ebcfced
Fix and deprecate Lit_commit_ish
EliahKagan Mar 14, 2024
b070e93
Make some broad mypy suppressions more specific
EliahKagan Mar 14, 2024
0b99041
Merge branch 'main' into doc-types
EliahKagan Mar 14, 2024
011cb0a
Apply Ruff auto-fixes not included in merge
EliahKagan Mar 14, 2024
74f3c2e
Help Ruff avoid a very long line
EliahKagan Mar 14, 2024
5778b7a
Use LBYL for imports where EAFP is a mypy type error
EliahKagan Mar 14, 2024
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
Prev Previous commit
Next Next commit
Temporarily rename Commit_ish to Old_commit_ish
And Lit_commit_ish to Lit_old_commit_ish.

This is temporary, and only for purposes of bookkeeping while this
type is split into two types.

Specifically, Old_commit_ish will go away soon, because each
occurrence of it will be changed to one of:

- A newly redefined Commit_ish union of types representing only git
  object types that are sometimes commit-ish.

- A newly introduced union (using some name formerly not used in
  GitPython) of all four types representing git object types, the
  same types as the old Commit_ish, here renamed Old_commit_ish,
  had overbroadly covered.

- Perhaps in some cases something else.

For context, see #1858 (including comments), and comments in #1859.
  • Loading branch information
EliahKagan committed Mar 10, 2024
commit 04a27531bf1d434a8da9d17298058d1f860fe019
4 changes: 2 additions & 2 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
Union,
)

from git.types import Commit_ish, Literal, PathLike
from git.types import Old_commit_ish, Literal, PathLike

if TYPE_CHECKING:
from subprocess import Popen
Expand Down Expand Up @@ -1127,7 +1127,7 @@ def move(
def commit(
self,
message: str,
parent_commits: Union[Commit_ish, None] = None,
parent_commits: Union[Old_commit_ish, None] = None,
head: bool = True,
author: Union[None, "Actor"] = None,
committer: Union[None, "Actor"] = None,
Expand Down
12 changes: 6 additions & 6 deletions git/objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from typing import Any, TYPE_CHECKING, Union

from git.types import PathLike, Commit_ish, Lit_commit_ish
from git.types import PathLike, Old_commit_ish, Lit_old_commit_ish

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -53,7 +53,7 @@ class Object(LazyMixin):
* "tag object": https://git-scm.com/docs/gitglossary#def_tag_object

:note:
See the :class:`~git.types.Commit_ish` union type.
See the :class:`~git.types.Old_commit_ish` union type.

:note:
:class:`~git.objects.submodule.base.Submodule` is defined under the hierarchy
Expand All @@ -77,7 +77,7 @@ class Object(LazyMixin):

__slots__ = ("repo", "binsha", "size")

type: Union[Lit_commit_ish, None] = None
type: Union[Lit_old_commit_ish, None] = None
"""String identifying (a concrete :class:`Object` subtype for) a git object type.

The subtypes that this may name correspond to the kinds of git objects that exist,
Expand All @@ -90,7 +90,7 @@ class Object(LazyMixin):
``None`` in concrete leaf subclasses representing specific git object types.

:note:
See also :class:`~git.types.Commit_ish`.
See also :class:`~git.types.Old_commit_ish`.
"""

def __init__(self, repo: "Repo", binsha: bytes):
Expand All @@ -113,7 +113,7 @@ def __init__(self, repo: "Repo", binsha: bytes):
)

@classmethod
def new(cls, repo: "Repo", id: Union[str, "Reference"]) -> Commit_ish:
def new(cls, repo: "Repo", id: Union[str, "Reference"]) -> Old_commit_ish:
"""
:return:
New :class:`Object` instance of a type appropriate to the object type behind
Expand All @@ -130,7 +130,7 @@ def new(cls, repo: "Repo", id: Union[str, "Reference"]) -> Commit_ish:
return repo.rev_parse(str(id))

@classmethod
def new_from_sha(cls, repo: "Repo", sha1: bytes) -> Commit_ish:
def new_from_sha(cls, repo: "Repo", sha1: bytes) -> Old_commit_ish:
"""
:return:
New object instance of a type appropriate to represent the given binary sha1
Expand Down
16 changes: 8 additions & 8 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast
from typing import Any, Iterator, Union

from git.types import Commit_ish, Literal, PathLike, TBD
from git.types import Old_commit_ish, Literal, PathLike, TBD

if TYPE_CHECKING:
from git.index import IndexFile
Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(
mode: Union[int, None] = None,
path: Union[PathLike, None] = None,
name: Union[str, None] = None,
parent_commit: Union[Commit_ish, None] = None,
parent_commit: Union[Old_commit_ish, None] = None,
url: Union[str, None] = None,
branch_path: Union[PathLike, None] = None,
) -> None:
Expand Down Expand Up @@ -213,7 +213,7 @@ def __repr__(self) -> str:

@classmethod
def _config_parser(
cls, repo: "Repo", parent_commit: Union[Commit_ish, None], read_only: bool
cls, repo: "Repo", parent_commit: Union[Old_commit_ish, None], read_only: bool
) -> SubmoduleConfigParser:
"""
:return:
Expand Down Expand Up @@ -264,7 +264,7 @@ def _clear_cache(self) -> None:
# END for each name to delete

@classmethod
def _sio_modules(cls, parent_commit: Commit_ish) -> BytesIO:
def _sio_modules(cls, parent_commit: Old_commit_ish) -> BytesIO:
"""
:return:
Configuration file as :class:`~io.BytesIO` - we only access it through the
Expand All @@ -277,7 +277,7 @@ def _sio_modules(cls, parent_commit: Commit_ish) -> BytesIO:
def _config_parser_constrained(self, read_only: bool) -> SectionConstraint:
""":return: Config parser constrained to our submodule in read or write mode"""
try:
pc: Union["Commit_ish", None] = self.parent_commit
pc: Union["Old_commit_ish", None] = self.parent_commit
except ValueError:
pc = None
# END handle empty parent repository
Expand Down Expand Up @@ -1242,7 +1242,7 @@ def remove(

return self

def set_parent_commit(self, commit: Union[Commit_ish, None], check: bool = True) -> "Submodule":
def set_parent_commit(self, commit: Union[Old_commit_ish, None], check: bool = True) -> "Submodule":
"""Set this instance to use the given commit whose tree is supposed to
contain the ``.gitmodules`` blob.

Expand Down Expand Up @@ -1495,7 +1495,7 @@ def url(self) -> str:
return self._url

@property
def parent_commit(self) -> "Commit_ish":
def parent_commit(self) -> "Old_commit_ish":
"""
:return:
:class:`~git.objects.commit.Commit` instance with the tree containing the
Expand Down Expand Up @@ -1557,7 +1557,7 @@ def children(self) -> IterableList["Submodule"]:
def iter_items(
cls,
repo: "Repo",
parent_commit: Union[Commit_ish, str] = "HEAD",
parent_commit: Union[Old_commit_ish, str] = "HEAD",
*Args: Any,
**kwargs: Any,
) -> Iterator["Submodule"]:
Expand Down
4 changes: 2 additions & 2 deletions git/objects/submodule/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from typing import TYPE_CHECKING, Union

from git.types import Commit_ish
from git.types import Old_commit_ish

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -77,7 +77,7 @@ def _clear_cache(self) -> None:

def update( # type: ignore[override]
self,
previous_commit: Union[Commit_ish, None] = None,
previous_commit: Union[Old_commit_ish, None] = None,
recursive: bool = True,
force_remove: bool = False,
init: bool = True,
Expand Down
4 changes: 2 additions & 2 deletions git/refs/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from typing import Any, Sequence, Union, TYPE_CHECKING

from git.types import PathLike, Commit_ish
from git.types import PathLike, Old_commit_ish

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -62,7 +62,7 @@ def orig_head(self) -> SymbolicReference:

def reset(
self,
commit: Union[Commit_ish, SymbolicReference, str] = "HEAD",
commit: Union[Old_commit_ish, SymbolicReference, str] = "HEAD",
index: bool = True,
working_tree: bool = False,
paths: Union[PathLike, Sequence[PathLike], None] = None,
Expand Down
4 changes: 2 additions & 2 deletions git/refs/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# typing ------------------------------------------------------------------

from typing import Any, Callable, Iterator, Type, Union, TYPE_CHECKING
from git.types import Commit_ish, PathLike, _T
from git.types import Old_commit_ish, PathLike, _T

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -81,7 +81,7 @@ def __str__(self) -> str:
# @ReservedAssignment
def set_object(
self,
object: Union[Commit_ish, "SymbolicReference", str],
object: Union[Old_commit_ish, "SymbolicReference", str],
logmsg: Union[str, None] = None,
) -> "Reference":
"""Special version which checks if the head-log needs an update as well.
Expand Down
8 changes: 4 additions & 4 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
TYPE_CHECKING,
cast,
)
from git.types import Commit_ish, PathLike
from git.types import Old_commit_ish, PathLike

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -278,7 +278,7 @@ def _get_ref_info(cls, repo: "Repo", ref_path: Union[PathLike, None]) -> Union[T
"""
return cls._get_ref_info_helper(repo, ref_path)

def _get_object(self) -> Commit_ish:
def _get_object(self) -> Old_commit_ish:
"""
:return:
The object our ref currently refers to. Refs can be cached, they will always
Expand Down Expand Up @@ -345,7 +345,7 @@ def set_commit(

def set_object(
self,
object: Union[Commit_ish, "SymbolicReference", str],
object: Union[Old_commit_ish, "SymbolicReference", str],
logmsg: Union[str, None] = None,
) -> "SymbolicReference":
"""Set the object we point to, possibly dereference our symbolic reference
Expand Down Expand Up @@ -404,7 +404,7 @@ def _get_reference(self) -> "SymbolicReference":

def set_reference(
self,
ref: Union[Commit_ish, "SymbolicReference", str],
ref: Union[Old_commit_ish, "SymbolicReference", str],
logmsg: Union[str, None] = None,
) -> "SymbolicReference":
"""Set ourselves to the given `ref`.
Expand Down
4 changes: 2 additions & 2 deletions git/refs/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# typing ------------------------------------------------------------------

from typing import Any, Type, Union, TYPE_CHECKING
from git.types import Commit_ish, PathLike
from git.types import Old_commit_ish, PathLike

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -82,7 +82,7 @@ def tag(self) -> Union["TagObject", None]:

# Make object read-only. It should be reasonably hard to adjust an existing tag.
@property
def object(self) -> Commit_ish: # type: ignore[override]
def object(self) -> Old_commit_ish: # type: ignore[override]
return Reference._get_object(self)

@classmethod
Expand Down
10 changes: 5 additions & 5 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
overload,
)

from git.types import PathLike, Literal, Commit_ish
from git.types import PathLike, Literal, Old_commit_ish

if TYPE_CHECKING:
from git.repo.base import Repo
Expand Down Expand Up @@ -196,7 +196,7 @@ def __init__(
self.summary = summary

@property
def old_commit(self) -> Union[str, SymbolicReference, Commit_ish, None]:
def old_commit(self) -> Union[str, SymbolicReference, Old_commit_ish, None]:
return self._old_commit_sha and self._remote.repo.commit(self._old_commit_sha) or None

@property
Expand Down Expand Up @@ -362,7 +362,7 @@ def __init__(
ref: SymbolicReference,
flags: int,
note: str = "",
old_commit: Union[Commit_ish, None] = None,
old_commit: Union[Old_commit_ish, None] = None,
remote_ref_path: Optional[PathLike] = None,
) -> None:
"""Initialize a new instance."""
Expand All @@ -381,7 +381,7 @@ def name(self) -> str:
return self.ref.name

@property
def commit(self) -> Commit_ish:
def commit(self) -> Old_commit_ish:
""":return: Commit of our remote ref"""
return self.ref.commit

Expand Down Expand Up @@ -438,7 +438,7 @@ def _from_line(cls, repo: "Repo", line: str, fetch_line: str) -> "FetchInfo":

# Parse operation string for more info.
# This makes no sense for symbolic refs, but we parse it anyway.
old_commit: Union[Commit_ish, None] = None
old_commit: Union[Old_commit_ish, None] = None
is_tag_operation = False
if "rejected" in operation:
flags |= cls.REJECTED
Expand Down
8 changes: 4 additions & 4 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
TBD,
PathLike,
Lit_config_levels,
Commit_ish,
Old_commit_ish,
CallableProgress,
Tree_ish,
assert_never,
Expand Down Expand Up @@ -696,7 +696,7 @@ def config_writer(self, config_level: Lit_config_levels = "repository") -> GitCo
"""
return GitConfigParser(self._get_config_path(config_level), read_only=False, repo=self, merge_includes=False)

def commit(self, rev: Union[str, Commit_ish, None] = None) -> Commit:
def commit(self, rev: Union[str, Old_commit_ish, None] = None) -> Commit:
"""The :class:`~git.objects.commit.Commit` object for the specified revision.
:param rev:
Expand Down Expand Up @@ -772,7 +772,7 @@ def iter_commits(

return Commit.iter_items(self, rev, paths, **kwargs)

def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Union[Commit_ish, None]]:
def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Union[Old_commit_ish, None]]:
R"""Find the closest common ancestor for the given revision
(:class:`~git.objects.commit.Commit`\s, :class:`~git.refs.tag.Tag`\s,
:class:`~git.refs.reference.Reference`\s, etc.).
Expand All @@ -797,7 +797,7 @@ def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Union[Commit_ish, None]]:
raise ValueError("Please specify at least two revs, got only %i" % len(rev))
# END handle input

res: List[Union[Commit_ish, None]] = []
res: List[Union[Old_commit_ish, None]] = []
try:
lines = self.git.merge_base(*rev, **kwargs).splitlines() # List[str]
except GitCommandError as err:
Expand Down
12 changes: 6 additions & 6 deletions git/repo/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Typing ----------------------------------------------------------------------

from typing import Union, Optional, cast, TYPE_CHECKING
from git.types import Commit_ish
from git.types import Old_commit_ish

if TYPE_CHECKING:
from git.types import PathLike
Expand Down Expand Up @@ -249,7 +249,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
raise NotImplementedError("commit by message search (regex)")
# END handle search

obj: Union[Commit_ish, "Reference", None] = None
obj: Union[Old_commit_ish, "Reference", None] = None
ref = None
output_type = "commit"
start = 0
Expand All @@ -271,7 +271,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
if token == "@":
ref = cast("Reference", name_to_object(repo, rev[:start], return_ref=True))
else:
obj = cast(Commit_ish, name_to_object(repo, rev[:start]))
obj = cast(Old_commit_ish, name_to_object(repo, rev[:start]))
# END handle token
# END handle refname
else:
Expand All @@ -296,7 +296,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
pass # Default.
elif output_type == "tree":
try:
obj = cast(Commit_ish, obj)
obj = cast(Old_commit_ish, obj)
obj = to_commit(obj).tree
except (AttributeError, ValueError):
pass # Error raised later.
Expand Down Expand Up @@ -369,7 +369,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
parsed_to = start
# Handle hierarchy walk.
try:
obj = cast(Commit_ish, obj)
obj = cast(Old_commit_ish, obj)
if token == "~":
obj = to_commit(obj)
for _ in range(num):
Expand Down Expand Up @@ -398,7 +398,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:

# Still no obj? It's probably a simple name.
if obj is None:
obj = cast(Commit_ish, name_to_object(repo, rev))
obj = cast(Old_commit_ish, name_to_object(repo, rev))
parsed_to = lr
# END handle simple name

Expand Down
Loading