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

Include TagObject in git.types.Tree_ish #1878

Merged
merged 1 commit into from
Mar 15, 2024
Merged
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
25 changes: 10 additions & 15 deletions git/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,18 @@
See also the :class:`Tree_ish` and :class:`Commit_ish` unions.
"""

Tree_ish = Union["Commit", "Tree"]
"""Union of :class:`~git.objects.base.Object`-based types that are inherently tree-ish.
Tree_ish = Union["Commit", "Tree", "TagObject"]
"""Union of :class:`~git.objects.base.Object`-based types that are sometimes tree-ish.

See gitglossary(7) on "tree-ish": https://git-scm.com/docs/gitglossary#def_tree-ish

:note:
This union comprises **only** the :class:`~git.objects.commit.Commit` and
:class:`~git.objects.tree.Tree` classes, **all** of whose instances are tree-ish.
This has been done because of the way GitPython uses it as a static type annotation.

:class:`~git.objects.tag.TagObject`, some but not all of whose instances are
tree-ish (those representing git tag objects that ultimately resolve to a tree or
commit), is not covered as part of this union type.
:class:`~git.objects.tree.Tree` and :class:`~git.objects.commit.Commit` are the
classes whose instances are all tree-ish. This union includes them, but also
:class:`~git.objects.tag.TagObject`, only **some** of whose instances are tree-ish.
EliahKagan marked this conversation as resolved.
Show resolved Hide resolved
Whether a particular :class:`~git.objects.tag.TagObject` peels (recursively
dereferences) to a tree or commit, rather than a blob, can in general only be known
at runtime.

:note:
See also the :class:`AnyGitObject` union of all four classes corresponding to git
Expand All @@ -102,12 +101,8 @@
commit-ish. This union type includes :class:`~git.objects.commit.Commit`, but also
:class:`~git.objects.tag.TagObject`, only **some** of whose instances are
EliahKagan marked this conversation as resolved.
Show resolved Hide resolved
commit-ish. Whether a particular :class:`~git.objects.tag.TagObject` peels
(recursively dereferences) to a commit can in general only be known at runtime.

:note:
This is an inversion of the situation with :class:`Tree_ish`. This union is broader
than all commit-ish objects, while :class:`Tree_ish` is narrower than all tree-ish
objects.
(recursively dereferences) to a commit, rather than a tree or blob, can in general
only be known at runtime.

:note:
See also the :class:`AnyGitObject` union of all four classes corresponding to git
Expand Down
Loading