Skip to content

Commit b186008

Browse files
Merge addIntegrationTests into jam
2 parents 61da546 + ae2120c commit b186008

3 files changed

Lines changed: 306 additions & 23 deletions

File tree

mypy/installtypes.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
def normalize_distribution_name(name: str) -> str:
2222
return _DIST_NORMALIZE_RE.sub("-", name).lower()
2323

24+
DIST_TO_MODULE_NAME: dict[str, str] = {
25+
"python-dateutil": "dateutil",
26+
"pyyaml": "yaml",
27+
"python-xlib": "Xlib",
28+
}
29+
2430

2531
def read_locked_packages(path: str) -> dict[str, str | None]:
2632
"""Read package name/version pairs from a pylock-like TOML file.
@@ -65,11 +71,21 @@ def resolve_stub_packages_from_lock(locked: Mapping[str, str | None]) -> list[st
6571
for dist_name in locked:
6672
if dist_name.startswith("types-"):
6773
continue
68-
candidates = {dist_name, dist_name.replace("-", "_")}
74+
75+
candidates = {
76+
dist_name,
77+
dist_name.replace("-", "_"),
78+
}
79+
80+
mapped_module = DIST_TO_MODULE_NAME.get(dist_name)
81+
if mapped_module is not None:
82+
candidates.add(mapped_module)
83+
6984
for module_name in candidates:
7085
stub = stub_distribution_name(module_name)
7186
if stub:
7287
stubs.add(stub)
88+
7389
typeshed_name = f"types-{dist_name}"
7490
if typeshed_name in known_stubs:
7591
stubs.add(typeshed_name)
@@ -82,4 +98,4 @@ def make_runtime_constraints(locked: Mapping[str, str | None]) -> list[str]:
8298
for name, version in sorted(locked.items()):
8399
if version:
84100
constraints.append(f"{name}=={version}")
85-
return constraints
101+
return constraints

mypy/main.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030
from mypy.errors import CompileError
3131
from mypy.find_sources import InvalidSourceList, create_source_list
3232
from mypy.fscache import FileSystemCache
33-
from mypy.installtypes import (
34-
make_runtime_constraints,
35-
read_locked_packages,
36-
resolve_stub_packages_from_lock,
37-
)
33+
from mypy.installtypes import make_runtime_constraints, read_locked_packages, resolve_stub_packages_from_lock
3834
from mypy.modulefinder import (
3935
BuildSource,
4036
FindModuleCache,
@@ -140,7 +136,11 @@ def main(
140136
if options.install_types_from_pylock is not None and not os.path.isfile(
141137
options.install_types_from_pylock
142138
):
143-
fail(f"error: Can't find lock file '{options.install_types_from_pylock}'", stderr, options)
139+
fail(
140+
f"error: Can't find lock file '{options.install_types_from_pylock}'",
141+
stderr,
142+
options,
143+
)
144144

145145
if options.install_types and not options.incremental:
146146
fail(
@@ -967,10 +967,10 @@ def add_invertible_flag(
967967
)
968968

969969
add_invertible_flag(
970-
"--no-strict-bytes",
971-
default=True,
972-
dest="strict_bytes",
973-
help="Treat bytearray and memoryview as subtypes of bytes",
970+
"--strict-bytes",
971+
default=False,
972+
strict_flag=True,
973+
help="Disable treating bytearray and memoryview as subtypes of bytes",
974974
group=strictness_group,
975975
)
976976

@@ -1306,13 +1306,7 @@ def add_invertible_flag(
13061306
parser.add_argument("--test-env", action="store_true", help=argparse.SUPPRESS)
13071307
# --local-partial-types disallows partial types spanning module top level and a function
13081308
# (implicitly defined in fine-grained incremental mode)
1309-
add_invertible_flag(
1310-
"--no-local-partial-types",
1311-
inverse="--local-partial-types",
1312-
default=True,
1313-
dest="local_partial_types",
1314-
help=argparse.SUPPRESS,
1315-
)
1309+
add_invertible_flag("--local-partial-types", default=False, help=argparse.SUPPRESS)
13161310
# --native-parser enables the native parser (experimental)
13171311
add_invertible_flag("--native-parser", default=False, help=argparse.SUPPRESS)
13181312
# --logical-deps adds some more dependencies that are not semantically needed, but

0 commit comments

Comments
 (0)