Skip to content

Commit da9fa1e

Browse files
committed
skip fuzzy matchign if type is ignored
1 parent 2541f06 commit da9fa1e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

mypy/build.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,11 @@ def module_not_found(
31923192
code = codes.IMPORT
31933193
errors.report(line, 0, msg.format(module=target), code=code)
31943194

3195-
if reason == ModuleNotFoundReason.NOT_FOUND and not errors.prefer_simple_messages():
3195+
if (
3196+
reason == ModuleNotFoundReason.NOT_FOUND
3197+
and not errors.prefer_simple_messages()
3198+
and line not in errors.ignored_lines.get(caller_state.xpath, {})
3199+
):
31963200
top_level_target = target.split(".")[0]
31973201
if not top_level_target.startswith("_"):
31983202
known_modules = get_known_modules(

test-data/unit/semanal-errors.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ import _pytest.fixtures
329329
main:1: error: Cannot find implementation or library stub for module named "_pytest.fixtures"
330330
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
331331

332+
[case testMissingModuleFuzzyMatchTypeIgnore]
333+
import numpyy # type: ignore
334+
[out]
335+
332336
[case testErrorInImportedModule]
333337
import m
334338
[file m.py]

0 commit comments

Comments
 (0)