gitpython-developers / GitPython

GitPython is a python library used to interact with Git repositories.

Home Page:http://gitpython.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`repo.blame` should allow passing `None` as the `rev` parameter.

Gaubbe opened this issue · comments

This issue only affects the type hint given to the rev parameter, as passing None to the function does work and gives the expected behavior, which is running the git blame -p -- <file> command without a revision, which gives back the blame including changes to the local working directory that haven't been committed yet.

While the code works at runtime, language servers such as pylance give back an error, as None is not a valid type according to the type hints.

Thanks for sharing your finding!

It does seems to make sense to adjust the annotations to explicitly allow this use-case.

I'll gladly make a pull request with the fix if you or other contributors don't have anything more to say about this issue.

Are there any other places in the code that comes to mind for which such a fix could also make sense? The only other git command that I use without specifiying a revision is git diff, but the Diffable interface seems to already support passing None as the other parameter.

Thanks for offering! It's OK to keep the PR focussed on the problem at hand.