Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork963
JoinPathlike Object to Tree#2094
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Byron commentedDec 14, 2025
Thanks a lot, this looks very good to me! It's a bit sad that we have some test duplication to validate various types, but I guess it's better than not having them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull request overview
This PR extends theTree.join andTree.__truediv__ API to support pathlike objects (such aspathlib.Path), enabling more Pythonic path handling when traversing Git tree objects. Previously, users had to explicitly convertPath objects to strings; now they can use them directly with the/ operator.
- Type annotations updated from
strtoPathLikefor both methods - Implementation uses
os.fspath()to convert PathLike objects to strings - Comprehensive test coverage added for PathLike support with various scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| git/objects/tree.py | Updatedjoin() and__truediv__() methods to acceptPathLike parameters; addedos.fspath() conversion; importedos module |
| test/test_tree.py | Added comprehensive test cases for string and PathLike path lookups covering simple, nested, folder, and invalid path scenarios; importedpytest,Repo, andPathLikeMock |
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Rename blob to treeCo-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
b8bb60e intogitpython-developers:mainUh oh!
There was an error while loading.Please reload this page.
This extends the
Tree.joinandTree.__truediv__API to allow a pathlike object.For example:
This did not work before without explicitly converting the
Pathto a string, but works now.