KEMBAR78
Crash when passing non-existant directory as --custom-typeshed-dir · Issue #4301 · python/mypy · GitHub
Skip to content

Crash when passing non-existant directory as --custom-typeshed-dir #4301

@joshstaiger

Description

@joshstaiger

Run mypy 0.550:

mypy --show-traceback --custom-typeshed-dir does_not_exist file.py

Where does_not_exist is any nonexistant directory.

This results in the following traceback:

file.py: error: Name '__builtins__' is not defined
file.py:1: error: Cannot find module named 'builtins'
file.py:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
file.py:1: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.550
Traceback (most recent call last):
  File "/Users/joshstaiger/anaconda/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/main.py", line 66, in main
    res = type_check_only(sources, bin_dir, options)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/main.py", line 119, in type_check_only
    options=options)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 214, in build
    graph = dispatch(sources, manager)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 1935, in dispatch
    process_graph(graph, manager)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 2199, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 2327, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/build.py", line 1836, in type_check_first_pass
    self.type_checker.check_first_pass()
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 196, in check_first_pass
    self.accept(d)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 283, in accept
    stmt.accept(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/nodes.py", line 764, in accept
    return visitor.visit_expression_stmt(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 2072, in visit_expression_stmt
    self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checkexpr.py", line 2363, in accept
    typ = node.accept(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/nodes.py", line 1024, in accept
    return visitor.visit_int_expr(self)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checkexpr.py", line 1320, in visit_int_expr
    return self.named_type('builtins.int')
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checkexpr.py", line 2387, in named_type
    return self.chk.named_type(name)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 2636, in named_type
    sym = self.lookup_qualified(name)
  File "/Users/joshstaiger/anaconda/lib/python3.6/site-packages/mypy/checker.py", line 2702, in lookup_qualified
    n = self.modules[parts[0]]
KeyError: 'builtins'
file.py:1: : note: use --pdb to drop into pdb

This is on Mac OS El Capitan 10.11.6, if that happens to make a difference.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions