python / python/mypy

Dmypy crashes when adding import and rechecking

Open
#10,047 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

crash topic-daemon
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Crash Report

Daemon crashes after adding an import flask statement and re-checking.

Traceback

Daemon crashed!
Traceback (most recent call last):
  File "mypy/dmypy_server.py", line 221, in serve
  File "mypy/dmypy_server.py", line 264, in run_command
  File "mypy/dmypy_server.py", line 323, in cmd_run
  File "mypy/dmypy_server.py", line 385, in check
  File "mypy/dmypy_server.py", line 564, in fine_grained_increment_follow_imports
  File "mypy/dmypy_server.py", line 679, in find_reachable_changed_modules
KeyError: 'jinja2'

To Reproduce

mkdir test && cd test
touch hi.py
dmypy run -- . # works
echo "import flask" > hi.py
dmypy run -- . # crashes
dmypy run -- . # works

Note that flask is not installed.

Your Environment

  • Mypy version used: 0.800
  • Mypy command-line flags: dmypy run -- .
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.9.1
  • Operating system and version: macOS 10.15.7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with mypy/dmypy_server.py and follow cmd_run, check, fine_grained_increment_follow_imports, and find_reachable_changed_modules using the provided reproduction. Investigate the missing 'jinja2' lookup after adding an unavailable flask import; done means the repeated dmypy run no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.