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

Error passing multiple keyword arguments from a dictionary #8328

Closed
CommanderPrS opened this issue Jan 24, 2020 · 1 comment
Closed

Error passing multiple keyword arguments from a dictionary #8328

CommanderPrS opened this issue Jan 24, 2020 · 1 comment

Comments

@CommanderPrS
Copy link

  • Are you reporting a bug, or opening a feature request?

This is a bug.

  • Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to simplify your case to a minimal repro.
def foo(a: str, b: int, c: bool) -> str:
    return "{}-{}-{}".format(a, b, c)


print(
    foo(
        a="pa",
        **{
           "b": 123,
           "c": True,
        },
    )
)

Python by itself is happy with this code, it works as expected:

>python test.py
pa-123-True
  • What is the actual behavior/output?

mypy is unhappy about the keyword arguments.

>mypy test.py
test.py:8:11: error: Argument 2 to "foo" has incompatible type "**Dict[str, int]"; expected "bool"  [arg-type]
            **{
              ^
Found 1 error in 1 file (checked 1 source file)
  • What is the behavior/output you expect?

mypy should be able to see that all the arguments passed have the correct types.

  • What are the versions of mypy and Python you are using?
>python --version --version
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)]

>mypy --version
mypy 0.750
  • Do you see the same issue after installing mypy from Git master?

I have not tried.

  • What are the mypy flags you are using? (For example --strict-optional)

Here is the contents of the mypy.ini file:

[mypy]
mypy_path = ./stubs

# How imports are handled
ignore_missing_imports = False
follow_imports = normal

# Enforce various type annotations
disallow_any_unimported = True
disallow_any_expr = False
disallow_any_decorated = False
disallow_any_explicit = False
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_decorators = True

# Various code quality checks
no_implicit_optional = True
strict_optional = True
warn_unused_ignores = True
warn_no_return = True
warn_return_any = True
warn_unreachable = True
warn_redundant_casts = True
allow_untyped_globals = False
allow_redefinition = False
strict_equality = True

# How error messages are printed
show_error_context = False
show_column_numbers = True
show_error_codes = True
pretty = True
  • If mypy crashed with a traceback, please paste the full traceback below.

No crash, just an error message.

@ilevkivskyi
Copy link
Member

Duplicate of #5382

@ilevkivskyi ilevkivskyi marked this as a duplicate of #5382 Jan 25, 2020
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

2 participants