From f46bf762d7381f30c5cda4b61e9b85d0057eb1cd Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Wed, 30 Aug 2023 18:35:13 -0700 Subject: [PATCH] Match note error codes to import error codes Fixes #16003 --- mypy/build.py | 2 +- test-data/unit/pep561.test | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/build.py b/mypy/build.py index 525d5f436e7e..39629c2dc455 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -2798,7 +2798,7 @@ def module_not_found( for note in notes: if "{stub_dist}" in note: note = note.format(stub_dist=stub_distribution_name(module)) - errors.report(line, 0, note, severity="note", only_once=True, code=codes.IMPORT) + errors.report(line, 0, note, severity="note", only_once=True, code=code) if reason is ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED: manager.missing_stub_packages.add(stub_distribution_name(module)) errors.set_import_context(save_import_context) diff --git a/test-data/unit/pep561.test b/test-data/unit/pep561.test index e8ebbd03dca7..9969c2894c36 100644 --- a/test-data/unit/pep561.test +++ b/test-data/unit/pep561.test @@ -167,6 +167,7 @@ a.bf(False) b.bf(False) a.bf(1) b.bf(1) +import typedpkg_ns.whatever as c # type: ignore[import-untyped] [out] testNamespacePkgWStubs.py:4: error: Skipping analyzing "typedpkg_ns.b.bbb": module is installed, but missing library stubs or py.typed marker testNamespacePkgWStubs.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports