Skip to content

Commit db58363

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1be3750 commit db58363

2 files changed

Lines changed: 123 additions & 140 deletions

File tree

mypy/build.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@
132132
from mypy.fixup import fixup_module
133133
from mypy.freetree import free_tree
134134
from mypy.fscache import FileSystemCache
135+
from mypy.known_modules import get_known_modules, reset_known_modules_cache
136+
from mypy.messages import best_matches, pretty_seq
135137
from mypy.metastore import FilesystemMetadataStore, MetadataStore, SqliteMetadataStore
136138
from mypy.modulefinder import (
137139
BuildSource as BuildSource,
@@ -150,8 +152,6 @@
150152
from mypy.renaming import LimitedVariableRenameVisitor, VariableRenameVisitor
151153
from mypy.stats import dump_type_stats
152154
from mypy.stubinfo import is_module_from_legacy_bundled_package, stub_distribution_name
153-
from mypy.known_modules import get_known_modules, reset_known_modules_cache
154-
from mypy.messages import best_matches, pretty_seq
155155
from mypy.types import Type, instance_cache
156156
from mypy.typestate import reset_global_state, type_state
157157
from mypy.util import json_dumps, json_loads
@@ -3196,8 +3196,7 @@ def module_not_found(
31963196
top_level_target = target.split(".")[0]
31973197
if not top_level_target.startswith("_"):
31983198
known_modules = get_known_modules(
3199-
manager.find_module_cache.stdlib_py_versions,
3200-
manager.options.python_version,
3199+
manager.find_module_cache.stdlib_py_versions, manager.options.python_version
32013200
)
32023201
matches = best_matches(top_level_target, known_modules, n=3)
32033202
matches = [m for m in matches if m.lower() != top_level_target.lower()]

mypy/known_modules.py

Lines changed: 120 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -16,150 +16,135 @@
1616

1717
from mypy.modulefinder import StdlibVersions
1818

19-
POPULAR_THIRD_PARTY_MODULES: Final[frozenset[str]] = frozenset({
20-
# Cloud
21-
"boto3",
22-
"botocore",
23-
"aiobotocore",
24-
"s3transfer",
25-
"s3fs",
26-
"awscli",
27-
28-
# HTTP / Networking
29-
"urllib3",
30-
"requests",
31-
"certifi",
32-
"idna",
33-
"charset_normalizer",
34-
"httpx",
35-
"httpcore",
36-
"aiohttp",
37-
"yarl",
38-
"multidict",
39-
"requests_oauthlib",
40-
"oauthlib",
41-
"h11",
42-
43-
# Typing / Extensions
44-
"typing_extensions",
45-
"annotated_types",
46-
"typing_inspection",
47-
48-
# Core Utilities
49-
"setuptools",
50-
"packaging",
51-
"pip",
52-
"wheel",
53-
"virtualenv",
54-
"platformdirs",
55-
"filelock",
56-
"zipp",
57-
"importlib_metadata",
58-
59-
# Data Science / Numerical
60-
"numpy",
61-
"pandas",
62-
"scipy",
63-
"pyarrow",
64-
65-
# Serialization / Config
66-
"yaml",
67-
"pydantic",
68-
"pydantic_core",
69-
"attrs",
70-
"tomli",
71-
"jsonschema",
72-
"jsonschema_specifications",
73-
"jmespath",
74-
75-
# Cryptography / Security
76-
"cryptography",
77-
"cffi",
78-
"pycparser",
79-
"rsa",
80-
"pyjwt",
81-
"pyasn1",
82-
"pyasn1_modules",
83-
84-
# Date / Time
85-
"dateutil",
86-
"pytz",
87-
"tzdata",
88-
89-
# Google / gRPC
90-
"google",
91-
"grpc",
92-
"grpc_status",
93-
"grpc_tools",
94-
"protobuf",
95-
"googleapis_common_protos",
96-
97-
# Testing
98-
"pytest",
99-
"pluggy",
100-
"iniconfig",
101-
102-
# CLI / Terminal
103-
"click",
104-
"colorama",
105-
"rich",
106-
"tqdm",
107-
108-
# Web Frameworks
109-
"starlette",
110-
111-
# Templates / Markup
112-
"jinja2",
113-
"markupsafe",
114-
"pygments",
115-
"markdown_it",
116-
"mdurl",
117-
118-
# Async
119-
"anyio",
120-
"greenlet",
121-
"aiosignal",
122-
"aiohappyeyeballs",
123-
"frozenlist",
124-
125-
# Database
126-
"sqlalchemy",
127-
128-
# Parsing / XML
129-
"pyparsing",
130-
"et_xmlfile",
131-
132-
# OpenTelemetry
133-
"opentelemetry",
134-
135-
# Other Popular Modules
136-
"six",
137-
"fsspec",
138-
"wrapt",
139-
"propcache",
140-
"rpds",
141-
"pathspec",
142-
"PIL",
143-
"psutil",
144-
"referencing",
145-
"trove_classifiers",
146-
"openpyxl",
147-
"dotenv",
148-
"yandexcloud",
149-
"cachetools",
150-
})
19+
POPULAR_THIRD_PARTY_MODULES: Final[frozenset[str]] = frozenset(
20+
{
21+
# Cloud
22+
"boto3",
23+
"botocore",
24+
"aiobotocore",
25+
"s3transfer",
26+
"s3fs",
27+
"awscli",
28+
# HTTP / Networking
29+
"urllib3",
30+
"requests",
31+
"certifi",
32+
"idna",
33+
"charset_normalizer",
34+
"httpx",
35+
"httpcore",
36+
"aiohttp",
37+
"yarl",
38+
"multidict",
39+
"requests_oauthlib",
40+
"oauthlib",
41+
"h11",
42+
# Typing / Extensions
43+
"typing_extensions",
44+
"annotated_types",
45+
"typing_inspection",
46+
# Core Utilities
47+
"setuptools",
48+
"packaging",
49+
"pip",
50+
"wheel",
51+
"virtualenv",
52+
"platformdirs",
53+
"filelock",
54+
"zipp",
55+
"importlib_metadata",
56+
# Data Science / Numerical
57+
"numpy",
58+
"pandas",
59+
"scipy",
60+
"pyarrow",
61+
# Serialization / Config
62+
"yaml",
63+
"pydantic",
64+
"pydantic_core",
65+
"attrs",
66+
"tomli",
67+
"jsonschema",
68+
"jsonschema_specifications",
69+
"jmespath",
70+
# Cryptography / Security
71+
"cryptography",
72+
"cffi",
73+
"pycparser",
74+
"rsa",
75+
"pyjwt",
76+
"pyasn1",
77+
"pyasn1_modules",
78+
# Date / Time
79+
"dateutil",
80+
"pytz",
81+
"tzdata",
82+
# Google / gRPC
83+
"google",
84+
"grpc",
85+
"grpc_status",
86+
"grpc_tools",
87+
"protobuf",
88+
"googleapis_common_protos",
89+
# Testing
90+
"pytest",
91+
"pluggy",
92+
"iniconfig",
93+
# CLI / Terminal
94+
"click",
95+
"colorama",
96+
"rich",
97+
"tqdm",
98+
# Web Frameworks
99+
"starlette",
100+
# Templates / Markup
101+
"jinja2",
102+
"markupsafe",
103+
"pygments",
104+
"markdown_it",
105+
"mdurl",
106+
# Async
107+
"anyio",
108+
"greenlet",
109+
"aiosignal",
110+
"aiohappyeyeballs",
111+
"frozenlist",
112+
# Database
113+
"sqlalchemy",
114+
# Parsing / XML
115+
"pyparsing",
116+
"et_xmlfile",
117+
# OpenTelemetry
118+
"opentelemetry",
119+
# Other Popular Modules
120+
"six",
121+
"fsspec",
122+
"wrapt",
123+
"propcache",
124+
"rpds",
125+
"pathspec",
126+
"PIL",
127+
"psutil",
128+
"referencing",
129+
"trove_classifiers",
130+
"openpyxl",
131+
"dotenv",
132+
"yandexcloud",
133+
"cachetools",
134+
}
135+
)
151136

152137

153138
_known_modules_cache: frozenset[str] | None = None
154139

140+
155141
def reset_known_modules_cache() -> None:
156142
global _known_modules_cache
157143
_known_modules_cache = None
158144

159145

160146
def get_stdlib_modules(
161-
stdlib_versions: StdlibVersions,
162-
python_version: tuple[int, int] | None = None,
147+
stdlib_versions: StdlibVersions, python_version: tuple[int, int] | None = None
163148
) -> frozenset[str]:
164149
modules: set[str] = set()
165150
for module, (min_ver, max_ver) in stdlib_versions.items():
@@ -177,8 +162,7 @@ def get_stdlib_modules(
177162

178163

179164
def get_known_modules(
180-
stdlib_versions: StdlibVersions | None = None,
181-
python_version: tuple[int, int] | None = None,
165+
stdlib_versions: StdlibVersions | None = None, python_version: tuple[int, int] | None = None
182166
) -> frozenset[str]:
183167
global _known_modules_cache
184168
if _known_modules_cache is not None:

0 commit comments

Comments
 (0)