Skip to content

Commit 1806074

Browse files
committed
Updates now python#109518 is merged
1 parent 50df501 commit 1806074

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

Lib/test/libregrtest/mypy.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ strict_optional = False
3131
# Various internal modules that typeshed deliberately doesn't have stubs for:
3232
[mypy-_abc.*,_opcode.*,_overlapped.*,_testcapi.*,_testinternalcapi.*,test.*]
3333
ignore_missing_imports = True
34-
disable_error_code = attr-defined,var-annotated
34+
35+
[mypy-test.support.*]
36+
disable_error_code = attr-defined,var-annotated,index,assignment

Tools/scripts/run_mypy_on_regrtest.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,49 @@
99

1010
import argparse
1111
import os
12-
import tempfile
1312
import shutil
1413
import subprocess
14+
import tempfile
1515
from pathlib import Path
1616
from typing import TypeAlias
1717

1818
ReturnCode: TypeAlias = int
1919

2020

21-
def run_mypy_on_libregrtest(stdlib_dir: Path) -> ReturnCode:
22-
stdlib_test_dir = stdlib_dir / "test"
21+
def run_mypy_on_libregrtest(root_dir: Path) -> ReturnCode:
22+
test_dot_support_dir = root_dir / "Lib/" / "test" / "support"
2323
# Copy `Lib/test/support/` into a tempdir and point MYPYPATH towards the tempdir,
2424
# so that mypy can see the classes and functions defined in `Lib/test/support/`
2525
with tempfile.TemporaryDirectory() as td:
2626
td_path = Path(td)
2727
(td_path / "test").mkdir()
28-
shutil.copytree(stdlib_test_dir / "support", td_path / "test" / "support")
28+
shutil.copytree(test_dot_support_dir, td_path / "test" / "support")
2929
mypy_command = [
3030
"mypy",
3131
"--config-file",
32-
"libregrtest/mypy.ini",
32+
"Lib/test/libregrtest/mypy.ini",
3333
]
3434
result = subprocess.run(
35-
mypy_command, cwd=stdlib_test_dir, env=os.environ | {"MYPYPATH": td}
35+
mypy_command, cwd=root_dir, env=os.environ | {"MYPYPATH": td}
3636
)
3737
return result.returncode
3838

3939

4040
def main() -> ReturnCode:
4141
parser = argparse.ArgumentParser("Script to run mypy on Lib/test/regrtest/")
4242
parser.add_argument(
43-
"--stdlib-dir",
44-
"-s",
43+
"--root-dir",
44+
"-r",
4545
type=Path,
4646
required=True,
47-
help="path to the Lib/ dir where the Python stdlib is located",
47+
help="path to the CPython repo root",
4848
)
4949
args = parser.parse_args()
50-
stdlib_dir = args.stdlib_dir
51-
if not (stdlib_dir.exists() and stdlib_dir.is_dir()):
52-
parser.error(
53-
"--stdlib-dir must point to a directory that exists on your filesystem!"
54-
)
55-
return run_mypy_on_libregrtest(args.stdlib_dir)
50+
root_dir = args.root_dir
51+
test_dot_support_dir = root_dir / "Lib" / "test" / "support"
52+
if not (test_dot_support_dir.exists() and test_dot_support_dir.is_dir()):
53+
parser.error("--root-dir must point to the root of a CPython clone!")
54+
return run_mypy_on_libregrtest(root_dir)
5655

5756

5857
if __name__ == "__main__":

0 commit comments

Comments
 (0)