Skip to content

MYPYPATH results in AssertionError: ImportedName(_collections.defaultdict) #5901

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
AstraLuma opened this issue Nov 16, 2018 · 5 comments
Closed

Comments

@AstraLuma
Copy link

If I leave something extra in $MYPYPATH (I'm not sure I understand what exactly), I get this error:

Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.6.3/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/main.py", line 92, in main
    res = build.build(sources, options, None, flush_errors, fscache)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/build.py", line 155, in build
    result = _build(sources, options, alt_lib_path, flush_errors, fscache)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/build.py", line 204, in _build
    graph = dispatch(sources, manager)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/build.py", line 2172, in dispatch
    process_graph(graph, manager)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/build.py", line 2469, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/build.py", line 2582, in process_stale_scc
    manager.semantic_analyzer.add_builtin_aliases(typing_mod)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/semanal.py", line 3415, in add_builtin_aliases
    target = self.named_type_or_none(target_name, [])
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/mypy/semanal.py", line 1369, in named_type_or_none
    assert isinstance(node, TypeInfo), node
AssertionError: ImportedName(_collections.defaultdict)
@gvanrossum
Copy link
Member

Probably the extra thing you have in $MYPYPATH overrides a basic stdlib module (e.g. typing). We can't help you further unless you show the contents of $MYPYPATH.

@ilevkivskyi
Copy link
Member

Have read the docs? https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports

Another note is we really need to implement #5241 (raised priority to high), my guess this is what causes users to abuse MYPYPATH.

@AstraLuma
Copy link
Author

I was about to write a big long thing about how it's a library that I contribute to and I've been working very hard to make it happy with both subclassing and mypy.

And then I realized that none of that work had actually been released to pypi yet, so what travis and mypy are seeing is a completely unannotated library.

Would it be possible to distinguish between "This library exists, but has no annotations" and "No, sorry, it's just not here at all"? The error message implies the latter, when in this case, the former seems to have happened.

@ilevkivskyi
Copy link
Member

Would it be possible to distinguish between "This library exists, but has no annotations" and "No, sorry, it's just not here at all"? The error message implies the latter, when in this case, the former seems to have happened.

We already have an issue for a better error message #4542

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