Skip to content

Commit d530091

Browse files
committed
Remove logic for legacy bundled stubs
1 parent f2a77ea commit d530091

File tree

3 files changed

+43
-78
lines changed

3 files changed

+43
-78
lines changed

mypy/build.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
from mypy.plugins.default import DefaultPlugin
9393
from mypy.renaming import LimitedVariableRenameVisitor, VariableRenameVisitor
9494
from mypy.stats import dump_type_stats
95-
from mypy.stubinfo import is_module_from_legacy_bundled_package, stub_distribution_name
95+
from mypy.stubinfo import stub_distribution_name
9696
from mypy.types import Type
9797
from mypy.typestate import reset_global_state, type_state
9898
from mypy.util import json_dumps, json_loads
@@ -2661,19 +2661,6 @@ def find_module_and_diagnose(
26612661

26622662
ignore_missing_imports = options.ignore_missing_imports
26632663

2664-
# Don't honor a global (not per-module) ignore_missing_imports
2665-
# setting for modules that used to have bundled stubs, as
2666-
# otherwise updating mypy can silently result in new false
2667-
# negatives. (Unless there are stubs but they are incomplete.)
2668-
global_ignore_missing_imports = manager.options.ignore_missing_imports
2669-
if (
2670-
is_module_from_legacy_bundled_package(id)
2671-
and global_ignore_missing_imports
2672-
and not options.ignore_missing_imports_per_module
2673-
and result is ModuleNotFoundReason.APPROVED_STUBS_NOT_INSTALLED
2674-
):
2675-
ignore_missing_imports = False
2676-
26772664
if skip_diagnose:
26782665
raise ModuleNotFound
26792666
if caller_state:

mypy/stubinfo.py

Lines changed: 41 additions & 56 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
@@ -27,54 +19,6 @@ def stub_distribution_name(module: str) -> str | None:
2719

2820
return None
2921

30-
31-
# Stubs for these third-party packages used to be shipped with mypy.
32-
#
33-
# Map package name to PyPI stub distribution name.
34-
legacy_bundled_packages: dict[str, str] = {
35-
"aiofiles": "types-aiofiles",
36-
"bleach": "types-bleach",
37-
"boto": "types-boto",
38-
"cachetools": "types-cachetools",
39-
"click_spinner": "types-click-spinner",
40-
"contextvars": "types-contextvars",
41-
"croniter": "types-croniter",
42-
"dataclasses": "types-dataclasses",
43-
"dateparser": "types-dateparser",
44-
"dateutil": "types-python-dateutil",
45-
"decorator": "types-decorator",
46-
"deprecated": "types-Deprecated",
47-
"docutils": "types-docutils",
48-
"first": "types-first",
49-
"gflags": "types-python-gflags",
50-
"markdown": "types-Markdown",
51-
"mock": "types-mock",
52-
"OpenSSL": "types-pyOpenSSL",
53-
"paramiko": "types-paramiko",
54-
"pkg_resources": "types-setuptools",
55-
"polib": "types-polib",
56-
"pycurl": "types-pycurl",
57-
"pymysql": "types-PyMySQL",
58-
"pyrfc3339": "types-pyRFC3339",
59-
"python2": "types-six",
60-
"pytz": "types-pytz",
61-
"pyVmomi": "types-pyvmomi",
62-
"redis": "types-redis",
63-
"requests": "types-requests",
64-
"retry": "types-retry",
65-
"simplejson": "types-simplejson",
66-
"singledispatch": "types-singledispatch",
67-
"six": "types-six",
68-
"slugify": "types-python-slugify",
69-
"tabulate": "types-tabulate",
70-
"toml": "types-toml",
71-
"typed_ast": "types-typed-ast",
72-
"tzlocal": "types-tzlocal",
73-
"ujson": "types-ujson",
74-
"waitress": "types-waitress",
75-
"yaml": "types-PyYAML",
76-
}
77-
7822
# Map package name to PyPI stub distribution name from typeshed.
7923
# Stubs for these packages were never bundled with mypy. Don't
8024
# include packages that have a release that includes PEP 561 type
@@ -87,44 +31,58 @@ def stub_distribution_name(module: str) -> str | None:
8731
non_bundled_packages_flat: dict[str, str] = {
8832
"_cffi_backend": "types-cffi",
8933
"_win32typing": "types-pywin32",
34+
"aiofiles": "types-aiofiles",
9035
"antlr4": "types-antlr4-python3-runtime",
9136
"assertpy": "types-assertpy",
9237
"atheris": "types-atheris",
9338
"authlib": "types-Authlib",
9439
"aws_xray_sdk": "types-aws-xray-sdk",
9540
"babel": "types-babel",
41+
"bleach": "types-bleach",
9642
"boltons": "types-boltons",
43+
"boto": "types-boto",
9744
"braintree": "types-braintree",
9845
"bs4": "types-beautifulsoup4",
9946
"bugbear": "types-flake8-bugbear",
47+
"cachetools": "types-cachetools",
10048
"caldav": "types-caldav",
10149
"capturer": "types-capturer",
10250
"cffi": "types-cffi",
10351
"chevron": "types-chevron",
10452
"click_default_group": "types-click-default-group",
10553
"click_log": "types-click-log",
54+
"click_spinner": "types-click-spinner",
10655
"click_web": "types-click-web",
10756
"colorama": "types-colorama",
10857
"commctrl": "types-pywin32",
10958
"commonmark": "types-commonmark",
11059
"consolemenu": "types-console-menu",
60+
"contextvars": "types-contextvars",
11161
"corus": "types-corus",
62+
"croniter": "types-croniter",
11263
"cronlog": "types-python-crontab",
11364
"crontab": "types-python-crontab",
11465
"crontabs": "types-python-crontab",
11566
"d3dshot": "types-D3DShot",
67+
"dataclasses": "types-dataclasses",
11668
"datemath": "types-python-datemath",
11769
"dateparser_data": "types-dateparser",
70+
"dateparser": "types-dateparser",
71+
"dateutil": "types-python-dateutil",
11872
"dde": "types-pywin32",
73+
"decorator": "types-decorator",
11974
"defusedxml": "types-defusedxml",
75+
"deprecated": "types-Deprecated",
12076
"docker": "types-docker",
12177
"dockerfile_parse": "types-dockerfile-parse",
12278
"docopt": "types-docopt",
79+
"docutils": "types-docutils",
12380
"editdistance": "types-editdistance",
12481
"entrypoints": "types-entrypoints",
12582
"exifread": "types-ExifRead",
12683
"fanstatic": "types-fanstatic",
12784
"farmhash": "types-pyfarmhash",
85+
"first": "types-first",
12886
"flake8_2020": "types-flake8-2020",
12987
"flake8_builtins": "types-flake8-builtins",
13088
"flake8_docstrings": "types-flake8-docstrings",
@@ -139,6 +97,7 @@ def stub_distribution_name(module: str) -> str | None:
13997
"fpdf": "types-fpdf2",
14098
"gdb": "types-gdb",
14199
"gevent": "types-gevent",
100+
"gflags": "types-python-gflags",
142101
"greenlet": "types-greenlet",
143102
"hdbcli": "types-hdbcli",
144103
"html5lib": "types-html5lib",
@@ -165,8 +124,10 @@ def stub_distribution_name(module: str) -> str | None:
165124
"lupa": "types-lupa",
166125
"lzstring": "types-lzstring",
167126
"m3u8": "types-m3u8",
127+
"markdown": "types-Markdown",
168128
"mmapfile": "types-pywin32",
169129
"mmsystem": "types-pywin32",
130+
"mock": "types-mock",
170131
"mypy_extensions": "types-mypy-extensions",
171132
"MySQLdb": "types-mysqlclient",
172133
"nanoid": "types-nanoid",
@@ -181,7 +142,9 @@ def stub_distribution_name(module: str) -> str | None:
181142
"odbc": "types-pywin32",
182143
"olefile": "types-olefile",
183144
"openpyxl": "types-openpyxl",
145+
"OpenSSL": "types-pyOpenSSL",
184146
"opentracing": "types-opentracing",
147+
"paramiko": "types-paramiko",
185148
"parsimonious": "types-parsimonious",
186149
"passlib": "types-passlib",
187150
"passpy": "types-passpy",
@@ -190,34 +153,45 @@ def stub_distribution_name(module: str) -> str | None:
190153
"perfmon": "types-pywin32",
191154
"pexpect": "types-pexpect",
192155
"PIL": "types-Pillow",
156+
"pkg_resources": "types-setuptools",
193157
"playhouse": "types-peewee",
194158
"playsound": "types-playsound",
159+
"polib": "types-polib",
195160
"portpicker": "types-portpicker",
196161
"psutil": "types-psutil",
197162
"psycopg2": "types-psycopg2",
198163
"pyasn1": "types-pyasn1",
199164
"pyaudio": "types-pyaudio",
200165
"pyautogui": "types-PyAutoGUI",
201166
"pycocotools": "types-pycocotools",
167+
"pycurl": "types-pycurl",
202168
"pyflakes": "types-pyflakes",
203169
"pygit2": "types-pygit2",
204170
"pygments": "types-Pygments",
205171
"pyi_splash": "types-pyinstaller",
206172
"PyInstaller": "types-pyinstaller",
173+
"pymysql": "types-PyMySQL",
207174
"pynput": "types-pynput",
175+
"pyrfc3339": "types-pyRFC3339",
208176
"pyscreeze": "types-PyScreeze",
209177
"pysftp": "types-pysftp",
210178
"pytest_lazyfixture": "types-pytest-lazy-fixture",
211179
"python_http_client": "types-python-http-client",
180+
"python2": "types-six",
212181
"pythoncom": "types-pywin32",
213182
"pythonwin": "types-pywin32",
183+
"pytz": "types-pytz",
184+
"pyVmomi": "types-pyvmomi",
214185
"pywintypes": "types-pywin32",
215186
"qrbill": "types-qrbill",
216187
"qrcode": "types-qrcode",
188+
"redis": "types-redis",
217189
"regex": "types-regex",
218190
"regutil": "types-pywin32",
219191
"reportlab": "types-reportlab",
220192
"requests_oauthlib": "types-requests-oauthlib",
193+
"requests": "types-requests",
194+
"retry": "types-retry",
221195
"RPi": "types-RPi.GPIO",
222196
"s2clientprotocol": "types-s2clientprotocol",
223197
"sass": "types-libsass",
@@ -228,26 +202,36 @@ def stub_distribution_name(module: str) -> str | None:
228202
"servicemanager": "types-pywin32",
229203
"setuptools": "types-setuptools",
230204
"shapely": "types-shapely",
205+
"simplejson": "types-simplejson",
206+
"singledispatch": "types-singledispatch",
207+
"six": "types-six",
208+
"slugify": "types-python-slugify",
231209
"slumber": "types-slumber",
232210
"sspicon": "types-pywin32",
233211
"stdlib_list": "types-stdlib-list",
234212
"str2bool": "types-str2bool",
235213
"stripe": "types-stripe",
214+
"tabulate": "types-tabulate",
236215
"tensorflow": "types-tensorflow",
237216
"tgcrypto": "types-TgCrypto",
238217
"timer": "types-pywin32",
218+
"toml": "types-toml",
239219
"toposort": "types-toposort",
240220
"tqdm": "types-tqdm",
241221
"translationstring": "types-translationstring",
242222
"tree_sitter_languages": "types-tree-sitter-languages",
243223
"tree_sitter": "types-tree-sitter",
244224
"ttkthemes": "types-ttkthemes",
225+
"typed_ast": "types-typed-ast",
226+
"tzlocal": "types-tzlocal",
227+
"ujson": "types-ujson",
245228
"unidiff": "types-unidiff",
246229
"untangle": "types-untangle",
247230
"usersettings": "types-usersettings",
248231
"uwsgi": "types-uWSGI",
249232
"uwsgidecorators": "types-uWSGI",
250233
"vobject": "types-vobject",
234+
"waitress": "types-waitress",
251235
"webob": "types-WebOb",
252236
"whatthepatch": "types-whatthepatch",
253237
"win2kras": "types-pywin32",
@@ -305,6 +289,7 @@ def stub_distribution_name(module: str) -> str | None:
305289
"xdgenvpy": "types-xdgenvpy",
306290
"Xlib": "types-python-xlib",
307291
"xmltodict": "types-xmltodict",
292+
"yaml": "types-PyYAML",
308293
"zstd": "types-zstd",
309294
"zxcvbn": "types-zxcvbn",
310295
# Stub packages that are not from typeshed

mypy/test/teststubinfo.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@
33
import unittest
44

55
from mypy.stubinfo import (
6-
is_module_from_legacy_bundled_package,
7-
legacy_bundled_packages,
86
non_bundled_packages_flat,
97
stub_distribution_name,
108
)
119

1210

1311
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("dataclasses")
1912

2013
def test_stub_distribution_name(self) -> None:
2114
assert stub_distribution_name("foobar_asdf") is None
@@ -29,6 +22,6 @@ def test_stub_distribution_name(self) -> None:
2922
assert stub_distribution_name("google") is None
3023

3124
def test_period_in_top_level(self) -> None:
32-
for packages in (non_bundled_packages_flat, legacy_bundled_packages):
25+
for packages in non_bundled_packages_flat:
3326
for top_level_module in packages:
3427
assert "." not in top_level_module

0 commit comments

Comments
 (0)