Errors related to imports different in fine-grained incremental mode

Open
#4,398 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the test cases in test-data/unit/fine-grained-modules.test, especially testDeletionOfSubmoduleTriggersImportFrom1 and testDeleteTwoFilesErrorsElsewhere, and compare their incremental and non-incremental output. Done means redundant import-related errors are removed, the preferred missing-module message is consistent, and error line numbers match across modes.

Written by the indexing model from the issue text.

Description

priority-1-normal topic-fine-grained-incremental

The example from test-data/unit/fine-grained-modules.test illustrates a problem with inconsistent import-related messages:

[case testDeletionOfSubmoduleTriggersImportFrom1]
from p import q
[file p/__init__.py]
[file p/q.py]
[delete p/q.py.2]
[file p/q.py.3]
[out]
==
main:1: error: Cannot find module named 'p.q'
-- TODO: The following messages are different compared to non-incremental mode
main:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
main:1: error: Module 'p' has no attribute 'q'
==

The expected behavior is to show only one of Cannot find module named 'p.q' / Module 'p' has no attribute 'q' (preferably the first alternative) in all modes.

Another test case which illustrates the problem:

[case testDeleteTwoFilesErrorsElsewhere]
import a
import b
a.f()
b.g()
[file a.py]
def f() -> None: pass
[file b.py]
def g() -> None: pass
[delete a.py.2]
[delete b.py.2]
[out]
==
main:1: error: Cannot find module named 'a'
main:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
-- TODO: Remove redundant error message
main:1: error: Cannot find module named 'b'
main:2: error: Cannot find module named 'b'

We should also make sure that error line numbers are consistent.

Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 18h
Merged PRs (30d)
54

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.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.