|
7 | 7 |
|
8 | 8 | 1. Parse sys.argv
|
9 | 9 | 2. Compute appropriate arguments for mypy
|
10 |
| -3. Stuff those arguments into sys.argv |
11 |
| -4. Run mypy.main('') |
12 |
| -5. Repeat steps 2-4 for other mypy runs (e.g. --py2) |
| 10 | +3. Pass those arguments to mypy.api.run() |
13 | 11 | """
|
14 | 12 |
|
15 | 13 | import argparse
|
@@ -95,15 +93,13 @@ def parse_version(v_str):
|
95 | 93 | return int(m.group(1)), int(m.group(2))
|
96 | 94 |
|
97 | 95 |
|
98 |
| -def is_supported(distribution, major): |
99 |
| - dist_path = Path("stubs", distribution) |
100 |
| - with open(dist_path / "METADATA.toml") as f: |
101 |
| - data = dict(tomli.loads(f.read())) |
| 96 | +def is_supported(distribution_path: Path, major: int) -> bool: |
| 97 | + data = dict(tomli.loads((distribution_path / "METADATA.toml").read_text())) |
102 | 98 | if major == 2:
|
103 | 99 | # Python 2 is not supported by default.
|
104 | 100 | return bool(data.get("python2", False))
|
105 | 101 | # Python 3 is supported by default.
|
106 |
| - return has_py3_stubs(dist_path) |
| 102 | + return has_py3_stubs(distribution_path) |
107 | 103 |
|
108 | 104 |
|
109 | 105 | # Keep this in sync with stubtest_third_party.py
|
@@ -278,10 +274,15 @@ def test_third_party_distribution(distribution: str, major: int, minor: int, arg
|
278 | 274 | return code, len(files)
|
279 | 275 |
|
280 | 276 |
|
| 277 | +def is_probably_stubs_folder(distribution: str, distribution_path: Path) -> bool: |
| 278 | + """Validate that `dist_path` is a folder containing stubs""" |
| 279 | + return distribution != ".mypy_cache" and distribution_path.is_dir() |
| 280 | + |
| 281 | + |
281 | 282 | def main():
|
282 | 283 | args = parser.parse_args()
|
283 | 284 |
|
284 |
| - versions = [(3, 10), (3, 9), (3, 8), (3, 7), (3, 6), (2, 7)] |
| 285 | + versions = [(3, 11), (3, 10), (3, 9), (3, 8), (3, 7), (3, 6), (2, 7)] |
285 | 286 | if args.python_version:
|
286 | 287 | versions = [v for v in versions if any(("%d.%d" % v).startswith(av) for av in args.python_version)]
|
287 | 288 | if not versions:
|
@@ -327,7 +328,12 @@ def main():
|
327 | 328 | if distribution == "SQLAlchemy":
|
328 | 329 | continue # Crashes
|
329 | 330 |
|
330 |
| - if not is_supported(distribution, major): |
| 331 | + distribution_path = Path("stubs", distribution) |
| 332 | + |
| 333 | + if not is_probably_stubs_folder(distribution, distribution_path): |
| 334 | + continue |
| 335 | + |
| 336 | + if not is_supported(distribution_path, major): |
331 | 337 | continue
|
332 | 338 |
|
333 | 339 | this_code, checked = test_third_party_distribution(distribution, major, minor, args)
|
|
0 commit comments