Skip to content

TypeError on built-ins when using keyword arguments is not found #5771

Closed

Description

@derhintze

Bug Report

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

  1. use a built-in method, e.g. get(), with a keyword argument
  2. run mypy, don't get an error
  3. 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

Activity

  1. derhintze commented on Jul 13, 2021

    @derhintze
    Author
  2. transferred this issue frompython/mypyon Jul 13, 2021
  3. added a commit that references this issue on Jul 13, 2021
    668f9b4
  4. JelleZijlstra commented on Jul 13, 2021

    @JelleZijlstra
    Member

    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.

  5. added a commit that references this issue on Nov 18, 2021
    0d7064c
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions