Skip to content

Commit 4670d2e

Browse files
committed
Merge branch 'master' into better-incompatible-messages
2 parents 4bf8cc3 + 0635422 commit 4670d2e

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

docs/source/command_line.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,11 @@ Miscellaneous
876876

877877
This flag causes mypy to install known missing stub packages for
878878
third-party libraries using pip. It will display the pip command
879-
line to run, and expects a confirmation before installing
880-
anything.
879+
that will be run, and expects a confirmation before installing
880+
anything. For security reasons, these stubs are limited to only a
881+
small subset of manually selected packages that have been
882+
verified by the typeshed team. These packages include only stub
883+
files and no executable code.
881884

882885
If you use this option without providing any files or modules to
883886
type check, mypy will install stub packages suggested during the
@@ -889,8 +892,8 @@ Miscellaneous
889892
.. note::
890893

891894
This is new in mypy 0.900. Previous mypy versions included a
892-
selection of third-party package stubs, instead of having them
893-
installed separately.
895+
selection of third-party package stubs, instead of having
896+
them installed separately.
894897

895898
.. option:: --junit-xml JUNIT_XML
896899

mypy/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2555,7 +2555,7 @@ def module_not_found(manager: BuildManager, line: int, caller_state: State,
25552555
if '{stub_dist}' in note:
25562556
note = note.format(stub_dist=legacy_bundled_packages[top_level])
25572557
errors.report(line, 0, note, severity='note', only_once=True, code=codes.IMPORT)
2558-
if reason is ModuleNotFoundReason.STUBS_NOT_INSTALLED:
2558+
if reason is ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED:
25592559
manager.missing_stub_packages.add(legacy_bundled_packages[top_level])
25602560
errors.set_import_context(save_import_context)
25612561

mypy/modulefinder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ModuleNotFoundReason(Enum):
5757
WRONG_WORKING_DIRECTORY = 2
5858

5959
# Stub PyPI package (typically types-pkgname) known to exist but not installed.
60-
STUBS_NOT_INSTALLED = 3
60+
APPROVED_STUBS_NOT_INSTALLED = 3
6161

6262
def error_message_templates(self, daemon: bool) -> Tuple[str, List[str]]:
6363
doc_link = "See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports"
@@ -71,7 +71,7 @@ def error_message_templates(self, daemon: bool) -> Tuple[str, List[str]]:
7171
elif self is ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS:
7272
msg = 'Skipping analyzing "{module}": found module but no type hints or library stubs'
7373
notes = [doc_link]
74-
elif self is ModuleNotFoundReason.STUBS_NOT_INSTALLED:
74+
elif self is ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED:
7575
msg = (
7676
'Library stubs not installed for "{module}" (or incompatible with Python {pyver})'
7777
)
@@ -231,7 +231,7 @@ def _find_module_non_stub_helper(self, components: List[str],
231231
or self.fscache.isfile(dir_path + ".py")):
232232
plausible_match = True
233233
if components[0] in legacy_bundled_packages:
234-
return ModuleNotFoundReason.STUBS_NOT_INSTALLED
234+
return ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED
235235
elif plausible_match:
236236
return ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS
237237
else:
@@ -311,7 +311,7 @@ def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult:
311311
if isinstance(non_stub_match, ModuleNotFoundReason):
312312
if non_stub_match is ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS:
313313
found_possible_third_party_missing_type_hints = True
314-
elif non_stub_match is ModuleNotFoundReason.STUBS_NOT_INSTALLED:
314+
elif non_stub_match is ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED:
315315
need_installed_stubs = True
316316
else:
317317
third_party_inline_dirs.append(non_stub_match)
@@ -413,7 +413,7 @@ def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult:
413413
return ancestor
414414

415415
if need_installed_stubs:
416-
return ModuleNotFoundReason.STUBS_NOT_INSTALLED
416+
return ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED
417417
elif found_possible_third_party_missing_type_hints:
418418
return ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS
419419
else:

0 commit comments

Comments
 (0)