Skip to content

Commit ee8eb89

Browse files
committed
rebase
1 parent 6424d0b commit ee8eb89

File tree

5 files changed

+6
-52
lines changed

5 files changed

+6
-52
lines changed

misc/update-stubinfo.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,10 @@ def main() -> None:
3030

3131
import mypy.stubinfo
3232

33-
mypy_p = set(mypy.stubinfo.non_bundled_packages_flat) | set(
34-
mypy.stubinfo.legacy_bundled_packages
35-
)
33+
mypy_p = set(mypy.stubinfo.non_bundled_packages_flat)
3634

3735
for p in typeshed_p_to_d.keys() & mypy_p:
3836
mypy_d = mypy.stubinfo.non_bundled_packages_flat.get(p)
39-
mypy_d = mypy_d or mypy.stubinfo.legacy_bundled_packages.get(p)
4037
if mypy_d != typeshed_p_to_d[p]:
4138
raise ValueError(
4239
f"stub_distribution mismatch for {p}: {mypy_d} != {typeshed_p_to_d[p]}"

mypy/build.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
from mypy.plugins.default import DefaultPlugin
133133
from mypy.renaming import LimitedVariableRenameVisitor, VariableRenameVisitor
134134
from mypy.stats import dump_type_stats
135-
from mypy.stubinfo import is_module_from_legacy_bundled_package, stub_distribution_name
135+
from mypy.stubinfo import stub_distribution_name
136136
from mypy.types import Type, instance_cache
137137
from mypy.typestate import reset_global_state, type_state
138138
from mypy.util import json_dumps, json_loads
@@ -2914,19 +2914,6 @@ def find_module_and_diagnose(
29142914

29152915
ignore_missing_imports = options.ignore_missing_imports
29162916

2917-
# Don't honor a global (not per-module) ignore_missing_imports
2918-
# setting for modules that used to have bundled stubs, as
2919-
# otherwise updating mypy can silently result in new false
2920-
# negatives. (Unless there are stubs but they are incomplete.)
2921-
global_ignore_missing_imports = manager.options.ignore_missing_imports
2922-
if (
2923-
is_module_from_legacy_bundled_package(id)
2924-
and global_ignore_missing_imports
2925-
and not options.ignore_missing_imports_per_module
2926-
and result is ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED
2927-
):
2928-
ignore_missing_imports = False
2929-
29302917
if skip_diagnose:
29312918
raise ModuleNotFound
29322919
if caller_state:

mypy/stubinfo.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
from __future__ import annotations
22

33

4-
def is_module_from_legacy_bundled_package(module: str) -> bool:
5-
top_level = module.split(".", 1)[0]
6-
return top_level in legacy_bundled_packages
7-
8-
94
def stub_distribution_name(module: str) -> str | None:
105
top_level = module.split(".", 1)[0]
116

12-
dist = legacy_bundled_packages.get(top_level)
13-
if dist:
14-
return dist
157
dist = non_bundled_packages_flat.get(top_level)
168
if dist:
179
return dist
@@ -31,7 +23,7 @@ def stub_distribution_name(module: str) -> str | None:
3123
# Stubs for these third-party packages used to be shipped with mypy.
3224
#
3325
# Map package name to PyPI stub distribution name.
34-
legacy_bundled_packages: dict[str, str] = {
26+
_legacy_bundled_packages: dict[str, str] = {
3527
"aiofiles": "types-aiofiles",
3628
"bleach": "types-bleach",
3729
"cachetools": "types-cachetools",
@@ -309,6 +301,7 @@ def stub_distribution_name(module: str) -> str | None:
309301
"lxml": "lxml-stubs", # https://github.com/lxml/lxml-stubs
310302
"scipy": "scipy-stubs", # https://github.com/scipy/scipy-stubs
311303
}
304+
non_bundled_packages_flat.update(_legacy_bundled_packages)
312305

313306

314307
non_bundled_packages_namespace: dict[str, dict[str, str]] = {

mypy/test/teststubinfo.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,10 @@
22

33
import unittest
44

5-
from mypy.stubinfo import (
6-
is_module_from_legacy_bundled_package,
7-
legacy_bundled_packages,
8-
non_bundled_packages_flat,
9-
stub_distribution_name,
10-
)
5+
from mypy.stubinfo import non_bundled_packages_flat, stub_distribution_name
116

127

138
class TestStubInfo(unittest.TestCase):
14-
def test_is_legacy_bundled_packages(self) -> None:
15-
assert not is_module_from_legacy_bundled_package("foobar_asdf")
16-
assert not is_module_from_legacy_bundled_package("PIL")
17-
assert is_module_from_legacy_bundled_package("pycurl")
18-
assert is_module_from_legacy_bundled_package("dateparser")
19-
209
def test_stub_distribution_name(self) -> None:
2110
assert stub_distribution_name("foobar_asdf") is None
2211
assert stub_distribution_name("pycurl") == "types-pycurl"
@@ -30,6 +19,6 @@ def test_stub_distribution_name(self) -> None:
3019
assert stub_distribution_name("google") is None
3120

3221
def test_period_in_top_level(self) -> None:
33-
for packages in (non_bundled_packages_flat, legacy_bundled_packages):
22+
for packages in non_bundled_packages_flat:
3423
for top_level_module in packages:
3524
assert "." not in top_level_module

test-data/unit/pythoneval.test

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,18 +1521,6 @@ x = 0
15211521
mypy: "tmp/typing.py" shadows library module "typing"
15221522
note: A user-defined top-level module with name "typing" is not supported
15231523

1524-
[case testIgnoreImportIfNoPython3StubAvailable]
1525-
# flags: --ignore-missing-imports
1526-
import scribe # No Python 3 stubs available for scribe
1527-
from scribe import x
1528-
import pytz # Python 3 stubs available for pytz
1529-
import foobar_asdf
1530-
import jack # This has a stubs package but was never bundled with mypy, so ignoring works
1531-
[out]
1532-
_testIgnoreImportIfNoPython3StubAvailable.py:4: error: Library stubs not installed for "pytz"
1533-
_testIgnoreImportIfNoPython3StubAvailable.py:4: note: Hint: "python3 -m pip install types-pytz"
1534-
_testIgnoreImportIfNoPython3StubAvailable.py:4: note: (or run "mypy --install-types" to install all missing stub packages)
1535-
_testIgnoreImportIfNoPython3StubAvailable.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
15361524

15371525
[case testNoPython3StubAvailable]
15381526
import scribe

0 commit comments

Comments
 (0)