rcmdnk / homebrew-file

Brewfile manager for Homebrew
http://homebrew-file.readthedocs.io/
MIT License
356 stars 29 forks source link

type annotation for **kw #160

Open rcmdnk opened 1 year ago

rcmdnk commented 1 year ago

by strict annotation check by mypy,

    arg_parser_opts: dict = {"add_help": False, "allow_abbrev": False}

https://github.com/rcmdnk/homebrew-file/blob/789ed640ea690dc4819c6e231d2884bd0d16e530/src/brew_file/main.py#L23

must have type annotation in the dict, like dict[str, bool].

But this leads to an error at func(**arg_parser_opts) like

Argument 2 to "ArgumentParser" has incompatible type "**Dict[str, bool]"; expected "Optional[str]"  [arg-type]

dict[str, Any] resolves this.

This problem is currently being discussed at: https://github.com/python/mypy/issues/5382.

rcmdnk commented 1 year ago

fixed at mypy 1.7 but need python 3.10 or later to use Unpack (and NotRequired)