Skip to content

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

Open
@maunzCache

Description

@maunzCache

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions