Skip to content

mypy error due to missing typing of **kwargs in Remote.fetch() #1472

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

Open
maunzCache opened this issue Jul 25, 2022 · 2 comments
Open

mypy error due to missing typing of **kwargs in Remote.fetch() #1472

maunzCache opened this issue Jul 25, 2022 · 2 comments
Labels
acknowledged c-typing Mypy causes warnings or errors when run help wanted

Comments

@maunzCache
Copy link

maunzCache commented Jul 25, 2022

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.

@Byron Byron added acknowledged help wanted c-typing Mypy causes warnings or errors when run labels Jul 25, 2022
@Byron
Copy link
Member

Byron commented Jul 25, 2022

Thanks for letting me know! A PR with a fix is definitely welcome.

@maunzCache
Copy link
Author

maunzCache commented Feb 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged c-typing Mypy causes warnings or errors when run help wanted
Development

No branches or pull requests

2 participants