python / python/mypy

No error about repeated keyword argument

Open
#14,585 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-calls
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Consider this code:

def f(**kwargs: object) -> None: ...
f(a=1, a=2) # no errors here

Expected Behavior
Error from mypy like this: SyntaxError: keyword argument repeated: a

Actual Behavior
At runtime:

  File "<some_file>", line 27
    f(a=1, a=2)
           ^^^
SyntaxError: keyword argument repeated: a

Mypy's output:

>mypy file.py
Success: no issues found in 1 source file

Your Environment

  • Mypy version used: mypy 1.0.0+dev.154fee110f274fe6214eff856b65d437ee299fdb (compiled: no) (I did pip install -U git+https://github.com/python/mypy.git several minutes ago)
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the Python snippet and mypy command shown in the report. Trace how mypy processes calls with repeated keyword arguments and locate the existing diagnostic tests for call expressions. Done means mypy reports an error for the duplicate keyword while preserving normal handling of **kwargs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.