You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError on built-ins when using keyword arguments is not found #5771
Many (most?) built-ins do not take keyword arguments (see Python issue 8706). Nevertheless, mypy does not report about the corresponding TypeError raised at runtime.
To Reproduce
use a built-in method, e.g. get(), with a keyword argument
run mypy, don't get an error
run the program, get a TypeError
MWE:
my_dict=dict(a=1)
a_value=my_dict.get('b', default='nothing to find')
print(a_value)
$ mypy tst.py
Success: no issues found in 1 source file
$ python tst.py
Traceback (most recent call last):
File "/opt/data/UserWork/hintze/my_work/tst.py", line 2, in<module>
a_value = my_dict.get('b', default='nothing to find')
TypeError: dict.get() takes no keyword arguments
Expected Behavior
I thought mypy would tell me about the TypeError...
Actual Behavior
...but it didn't.
Your Environment
Mypy version used: 0.901
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Python version used: Python 3.9.1
Operating system and version: [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
This must be fixed in typeshed for each individual function. I opened #5772 to fix a number of dict methods. If you have any other concrete examples, please list them here or just open a PR.
Activity
derhintze commentedon Jul 13, 2021
see also https://stackoverflow.com/questions/68322662
Make Mapping/MutableMapping params positional-only
JelleZijlstra commentedon Jul 13, 2021
This must be fixed in typeshed for each individual function. I opened #5772 to fix a number of dict methods. If you have any other concrete examples, please list them here or just open a PR.
Make Mapping/MutableMapping params positional-only (#5772)