Skip to content

No error about repeated keyword argument #14585

Open
@denballakh

Description

@denballakh

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

Activity

added
topic-callsFunction calls, *args, **kwargs, defaults
and removed
bugmypy got something wrong
on Feb 4, 2023
A5rocks

A5rocks commented on Feb 7, 2023

@A5rocks
Collaborator

Weirdly enough, looks like mypy used to warn about this, but this error was removed between v0.812 and v0.902 (based on runs in mypy-play).

I'll go ahead and bisect! [will edit this]

hauntsaninja

hauntsaninja commented on Feb 7, 2023

@hauntsaninja
Collaborator

@A5rocks if your bisection proves mysterious, I think there might be some Python version difference in whatever mypy-play.net is using

A5rocks

A5rocks commented on Feb 7, 2023

@A5rocks
Collaborator

It does appear mysterious, I tried 53ec9f3 (very much before v0.812) and it passed without errors. I'm not sure the proper way to do this.

hauntsaninja

hauntsaninja commented on Feb 7, 2023

@hauntsaninja
Collaborator

If I had to guess, it would be something like mypy-play.net is running 0.812 with Python 3.8 and 0.902 with Python 3.9. Or something like that

JelleZijlstra

JelleZijlstra commented on Feb 7, 2023

@JelleZijlstra
Member

Possibly relevant:

% ~/.pyenv/versions/3.8.16/bin/python -c 'import ast; ast.parse("f(a=1, a=2)")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/jelle/.pyenv/versions/3.8.16/lib/python3.8/ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
SyntaxError: keyword argument repeated
% ~/.pyenv/versions/3.10.9/bin/python -c 'import ast; ast.parse("f(a=1, a=2)")'
%
A5rocks

A5rocks commented on Feb 7, 2023

@A5rocks
Collaborator

That error does look like what mypy spit out! That would explain it, even if I can't on a cursory glance figure out where mypy-play would be overriding its default version of 3.10 (ymyzk/mypy-playground@c6d07eb)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuretopic-callsFunction calls, *args, **kwargs, defaults

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JelleZijlstra@hauntsaninja@A5rocks@denballakh@ichard26

        Issue actions

          No error about repeated keyword argument · Issue #14585 · python/mypy