8000 Crash with star imports and new file in the build · Issue #6110 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Crash with star imports and new file in the build #6110

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
ilevkivskyi opened this issue Dec 27, 2018 · 0 comments · Fixed by #6179
Closed

Crash with star imports and new file in the build #6110

ilevkivskyi opened this issue Dec 27, 2018 · 0 comments · Fixed by #6179

Comments

@ilevkivskyi
Copy link
Member

This test case:

[case testAddedSubStar]
# cmd: mypy -m a pack pack.mod b
# cmd2: mypy -m other
[file a.py]
from pack import *
[file pack/__init__.py]
[file pack/mod.py]
[file b.py]
import pack.mod
[file other.py]
import a
[out]
[out2]

crashes with

/Users/ilevkivskyi/src/mypy/mypy/build.py:157: in build
    result = _build(sources, options, alt_lib_path, flush_errors, fscache)
/Users/ilevkivskyi/src/mypy/mypy/build.py:207: in _build
    graph = dispatch(sources, manager)
/Users/ilevkivskyi/src/mypy/mypy/build.py:2214: in dispatch
    process_graph(graph, manager)
/Users/ilevkivskyi/src/mypy/mypy/build.py:2505: in process_graph
    process_fresh_modules(graph, prev_scc, manager)
/Users/ilevkivskyi/src/mypy/mypy/build.py:2591: in process_fresh_modules
    graph[id].fix_cross_refs()
/Users/ilevkivskyi/src/mypy/mypy/build.py:1598: in fix_cross_refs
    self.options.use_fine_grained_cache)
/Users/ilevkivskyi/src/mypy/mypy/fixup.py:25: in fixup_module
    node_fixer.visit_symbol_table(tree.names)
/Users/ilevkivskyi/src/mypy/mypy/fixup.py:77: in visit_symbol_table
    self.quick_and_dirty)
/Users/ilevkivskyi/src/mypy/mypy/fixup.py:261: in lookup_qualified_stnode
    return lookup_fully_qualified(name, modules, raise_on_missing=not quick_and_dirty)
/Users/ilevkivskyi/src/mypy/mypy/lookup.py:47: in lookup_fully_qualified
    assert key in names, "Cannot find %s for %s" % (key, name)
AssertionError: Cannot find mod for pack.mod

I think this is high priority because the crash affects users who adds new files to typed builds in existing code bases. There must be another way to reproduce this where all files from first command are also present in the second, but I didn't find a simple version of it.

Anyway, the crux seems to be the interference between lack of dependencies from star import (that can also import modules), and add_submodules_to_parent_modules().

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

Successfully merging a pull request may close this issue.

1 participant
0