-
-
Notifications
You must be signed in to change notification settings - Fork 954
Issue 1261 #1264
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
Issue 1261 #1264
Conversation
I accessed private variables instead of adding getters, because other parts of the code do the same and I didn't know if there was a reason for it. E.g.: remote.py line 409: (...) RemoteReference._common_path_default (...)
I initially wanted to add parameterized, but there was an issue somewhere, which is why I decided to just collect the errors
Thanks a lot!
With tox -e type
you should be able to pacify the type checker. It looks like it's not sure startswith
actually is available.
I come from a strongly typed language, so this caught me unawares.
since reference.py doesn't do a PathLike check, I removed mine, too.
reference.py:
def __init__(self, repo, path, check_path=True):
"""Initialize this instance
:param repo: Our parent repository
:param path:
Path relative to the .git/ directory pointing to the ref in question, i.e.
refs/heads/master
:param check_path: if False, you can provide any path. Otherwise the path must start with the
default path prefix of this type."""
if check_path and not path.startswith(self._common_path_default + '/'):
raise ValueError("Cannot instantiate %r from path %s" % (self.__class__.__name__, path))
super(Reference, self).__init__(repo, path)
Weird, that my tests ran through without issues on Python 3.9.5 ̄\(ツ)/ ̄ (Without tux, just ran the unit test in my IDE)
I come from a strongly typed language, so this caught me unawares.
I stopped trying to understand or follow or write python many years ago, too, and I am blissfully unaware of how the typing really works. Removing types is quite alright here I think and more knowledgable individuals can add them later if they see benefits.
Anyway, with a tiny adjustment it worked as expected. Thanks a lot for your contribution - thanks to you GitPython finally does as it says on the packaging (in this instance) 10 years or so later 😅.
Fixes #1261