Skip to content
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

type annotation for **kw #160

Open
rcmdnk opened this issue Mar 13, 2023 · 1 comment
Open

type annotation for **kw #160

rcmdnk opened this issue Mar 13, 2023 · 1 comment

Comments

@rcmdnk
Copy link
Owner

rcmdnk commented Mar 13, 2023

by strict annotation check by mypy,

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

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

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: python/mypy#5382.

@rcmdnk
Copy link
Owner Author

rcmdnk commented Nov 19, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant