Skip to content

Simplest list assignment fails #2023

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

Closed
elazarg opened this issue Aug 14, 2016 · 1 comment
Closed

Simplest list assignment fails #2023

elazarg opened this issue Aug 14, 2016 · 1 comment

Comments

@elazarg
Copy link
Contributor

elazarg commented Aug 14, 2016

Adding the following test crashes:

[case testListSimplest]
a = [1]

Results

  ...
  File ".../mypy/mypy/checker.py", line 2238, in lookup_qualified
    return n.names[parts[-1]]
KeyError: 'list'
@Michael0x2a
Copy link
Collaborator

This is due to a quirk of mypy's test framework. To speed up the tests and make debugging easier, what mypy's test framework will do is load up a very limited subset of Python's builtins, which, incidentally, doesn't lists.

To fix this, you can include one of the "builtins extension" files in test-data/unit/fixtures to augment the builtins by doing:

[case testListSimplest]
a = [1]
[builtins fixtures/list.py]

You can see examples of test cases doing this inside the check-list.text file. But yeah, it's not a perfect system and can be pretty confusing to debug the first time around -- for more context about this system/suggestions people have made, see #890 and #1675.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants