homebrew-file icon indicating copy to clipboard operation
homebrew-file copied to clipboard

type annotation for **kw

Open rcmdnk opened this issue 2 years ago • 1 comments

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 avatar Mar 13 '23 06:03 rcmdnk

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

rcmdnk avatar Nov 19 '23 11:11 rcmdnk