GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Respect `os.Pathlike` by George-Ogden · Pull Request #2086 · gitpython-developers/GitPython Conversation
Contributor
Fixes #2085
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Byron
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks better indeed. Feel free to use AI for that, it's quite good at this usually. The idea is to prove that the changes actually make something possible that wasn't possible before.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. URL is not a path though.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
|
I've added a few tests, but lots of the calls work on internal APIs, so they won't make much difference. In these cases, calling |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That's great, thanks a lot!
What should be shown in the tests is that it can now handle filepaths that don't decode with the standard encoding.
Candidate tests are:
index.add with a strange pathfspath and see which tests fail, then it's clear where to add a test with a 'special' path.Thanks for making this happen, and thanks for your understanding - we can't just make changes hoping it will work or doesn't make things work, but there must be real evidence that this is desirable. And we can only have that with tests that fail without this change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I am putting the PR back to draft until there are tests that use the new "can handle paths encoding independently from the runtime encoding" to prove the changes are effective. Thanks again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, I meant to add this comment with the changes I made yesterday: For example, the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
No problem! What I mean is that the point of this conversion is to prevent decoding issues related to paths. I.e. the user passes a filesystem path, but internally GitPython runs You'd have to go back to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've added some non-ASCII characters into the tests. However, the main point of the pull request is with objects that follow the import os from dataclasses import dataclass @dataclass class CustomPathlike: path: str def __fspath__(self) -> str: return self.path custom_pathlike = CustomPathlike("folder/file") str(custom_pathlike) # "CustomPathlike(path='folder/file')" - fails in "git add CustomPathlike(path='folder/file')" os.fspath(custom_pathlike) # "folder/file" - works in "git add folder/file" I realise that that was unclear in both the PR and the original issue (so I've added this example to the original issue). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks a lot, this definitely helped me understand that these changes aren't meant to address that one thing I thought they do 😅. My feeling is that the added tests don't actually fail on master, and thus should be removed. But if they do, please feel free to put them into a separate PR so I see them failing. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
See #2088 for failing tests |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for giving it a shot. Admittedly, @2088 is surprisingly complex and fails in more places than just the two I thought it would fail in. To my mind, a cherry-pick of 1710626 onto Do you want to try again, or remove the added tests here in absence of a demonstration of failure? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've done that in #2089 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks a lot for your patience, just one more thing: 1710626 adds tests which I believe should have shown that they won't work on If you don't feel like this has a chance to be fixed, then I think these tests can be removed by force-pushing without this commit for this PR to be merged. Otherwise, there can be a PR on Thank you, and… we will get there :). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
However, both Lines 86 to 98 in 1710626
and Lines 985 to 994 in 0fcf291
Ran on main successfully (and were included before this PR)
The difference in Lines 1216 to 1222 in 1710626
which fails on main is that the path is wrapped in a PathLikeMock, which has an interface similar to the one described above:Lines 55 to 60 in 1710626
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I see, thanks for clarifying and digging out the non-unicode tests on Then I even more so think that the tests in 1710626 as duplicates of the tests above serve no purpose. The |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This reverts commit 1710626.
There was an error while loading. Please reload this page.
|
All reverted! I agree that the tests don't add much. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Alright, let's do this! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks, that's great 🥳. Can you release a new version please? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I will do this at the end of the year, time for more fixes and features to be collected. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Pathlike type hint is not respected
There was an error while loading. Please reload this page.