GitPython
GitPython copied to clipboard
mypy error due to missing typing of **kwargs in Remote.fetch()
Just happen to notice that in GitPython == 3.1.27
the static typing pip mypy fails to recognize the **kwargs
of Remote.fetch()
in remote.py
. This happens because the kwargs argument is typed as Any, which is plausible but may be narrowed down to e.g. Union[None, Dict[str, int, bool]]
. For the correct list of possible types we'd need to check docs at git-fetch.
Use case is the following code snippet:
def fetch_all(self, repository: git.Repo) -> List[git.FetchInfo]:
fetch_kwargs = {'tags': True, 'force': True, 'prune': True, 'prune-tags': True}
origin_server = repository.remotes.origin
origin_server.fetch(**fetch_kwargs) # Note: mypy does not recognize kwargs because GitPython does type it as Any
fetch_info_list = origin_server.pull()
return fetch_info_list
(Code above is my custom code and not part of this project!)
Edit: Using mypy==0.971
and mypy-extensions==0.4.3
. Not sure if mypy should ignore this at least we can help it find a potential type.
Thanks for letting me know! A PR with a fix is definitely welcome.
Thanks for acknowledging this issue. I'll try to come up with something but it might take some time.
Edit: I checked out the repository and noticed some tests failing but i am using Python 3.11 so that might be bad. Not sure if i can start on this issue.