python / python/mypy

`dmypy suggest` crashes if the checked files emit messages and suggesting a stdlib function (?)

Open
#21,765 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

$ dmypy run -- --config-file=mypy-test.ini
Daemon started
pkg/__init__.py:1: note: Revealed type is "Literal[1]?"
Success: no issues found in 1 source file
$ dmypy suggest os.path.islink --callsites
pkg/__init__.py:1: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
  ...
File ".../mypy/errors.py", line 684, in _add_error_info
  assert file not in self.flushed_files

Project:

  • mypy-test.ini:
    [mypy]
    files = pkg/
    
  • pkg/__init__.py
    reveal_type(1)
    

The crash happens when:

  • One of the modules that are checked is emitting some kind of message (either note or error);
  • The suggestion is something from mypy's automatically loaded modules (I've only tested standard library ones). Suggesting something from the checked modules does not cause the crash.

Your Environment

  • Mypy version used: 2.3, master
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.13
  • Operating system and version: Ubuntu 22.04

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

Reproduce with the shown mypy-test.ini, pkg/init.py, and the dmypy run and dmypy suggest os.path.islink --callsites commands. Start at mypy/errors.py line 684 and trace how messages are flushed before suggestions for automatically loaded modules. Done means the suggestion no longer crashes when checked files emit notes or errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.