Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match note error codes to import error codes #16004

Merged
merged 3 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def _add_error_info(self, file: str, info: ErrorInfo) -> None:
self.error_info_map[file].append(info)
if info.blocker:
self.has_blockers.add(file)
if info.code is IMPORT:
if info.code in (IMPORT, IMPORT_UNTYPED, IMPORT_NOT_FOUND):
self.seen_import_error = True

def _filter_error(self, file: str, info: ErrorInfo) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion mypy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from mypy.version import __version__

try:
from lxml import etree # type: ignore[import]
from lxml import etree # type: ignore[import-untyped]

LXML_INSTALLED = True
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion mypy/test/testcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from mypy.test.update_data import update_testcase_output

try:
import lxml # type: ignore[import]
import lxml # type: ignore[import-untyped]
except ImportError:
lxml = None

Expand Down
2 changes: 1 addition & 1 deletion mypy/test/testcmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)

try:
import lxml # type: ignore[import]
import lxml # type: ignore[import-untyped]
except ImportError:
lxml = None

Expand Down
4 changes: 2 additions & 2 deletions mypy/test/testreports.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from mypy.test.helpers import Suite, assert_equal

try:
import lxml # type: ignore[import]
import lxml # type: ignore[import-untyped]
except ImportError:
lxml = None

Expand All @@ -22,7 +22,7 @@ def test_get_line_rate(self) -> None:

@pytest.mark.skipif(lxml is None, reason="Cannot import lxml. Is it installed?")
def test_as_xml(self) -> None:
import lxml.etree as etree # type: ignore[import]
import lxml.etree as etree # type: ignore[import-untyped]

cobertura_package = CoberturaPackage("foobar")
cobertura_package.covered_lines = 21
Expand Down
1 change: 1 addition & 0 deletions test-data/unit/pep561.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down