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

No error about repeated keyword argument #14585

Open
denballakh opened this issue Feb 2, 2023 · 6 comments
Open

No error about repeated keyword argument #14585

denballakh opened this issue Feb 2, 2023 · 6 comments
Labels
feature topic-calls Function calls, *args, **kwargs, defaults

Comments

@denballakh
Copy link
Contributor

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
@denballakh denballakh added the bug mypy got something wrong label Feb 2, 2023
@ichard26 ichard26 added feature topic-calls Function calls, *args, **kwargs, defaults and removed bug mypy got something wrong labels Feb 4, 2023
@A5rocks
Copy link
Contributor

A5rocks commented Feb 7, 2023

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
Copy link
Collaborator

hauntsaninja commented Feb 7, 2023

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

@A5rocks
Copy link
Contributor

A5rocks commented Feb 7, 2023

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
Copy link
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
Copy link
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
Copy link
Contributor

A5rocks commented Feb 7, 2023

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
Labels
feature topic-calls Function calls, *args, **kwargs, defaults
Projects
None yet
Development

No branches or pull requests

5 participants