Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38bad87

Browse files
committed
ruff format compat, use basedpyright, simplify error message and conditional
1 parent 5444684 commit 38bad87

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

requirements/test_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pytest-xdist
88
pytest-timeout
99
# For testing types
1010
mypy==1.19.1
11-
pyright
11+
basedpyright
1212
# for optional f2py encoding detection
1313
charset-normalizer
1414
tzdata

tools/pyright_completeness.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
We use `--ignoreexternal` to avoid "partially unknown" reports coming from the stdlib
1111
`numbers` module, see https://github.com/microsoft/pyright/discussions/9911.
1212
"""
13+
1314
import argparse
1415
import fnmatch
1516
import json
@@ -38,7 +39,9 @@ def run_pyright_with_coverage(
3839
pyright_args: list[str],
3940
exclude_like: Sequence[str],
4041
) -> int:
41-
result = subprocess.run(["pyright", *pyright_args], capture_output=True, text=True)
42+
result = subprocess.run(
43+
["basedpyright", *pyright_args], capture_output=True, text=True
44+
)
4245

4346
try:
4447
data = json.loads(result.stdout)
@@ -55,21 +58,19 @@ def run_pyright_with_coverage(
5558
if not any(fnmatch.fnmatch(x["name"], pattern) for pattern in exclude_like)
5659
and x["isExported"]
5760
]
58-
cov_percent = (
59-
sum(x["isTypeKnown"] for x in matched_symbols) / len(matched_symbols) * 100
60-
)
61+
covered = sum(x["isTypeKnown"] for x in matched_symbols) / len(matched_symbols)
6162
else:
62-
cov_percent = data["typeCompleteness"]["completenessScore"] * 100
63+
covered = data["typeCompleteness"]["completenessScore"]
64+
sys.stderr.write(result.stderr)
65+
if covered < 1:
66+
sys.stdout.write(f"Coverage {covered:.1%} is below minimum required 100%")
67+
return 1
6368

6469
sys.stderr.write(result.stderr)
65-
if cov_percent < 100:
66-
sys.stdout.write(
67-
f"Coverage {cov_percent:.1f}% is below minimum required 100%"
68-
)
70+
if covered < 100:
71+
sys.stdout.write(f"Coverage {covered:.1f}% is below minimum required 100%")
6972
return 1
70-
sys.stdout.write(
71-
f"Coverage {cov_percent:.1f}% is at or above minimum required 100%"
72-
)
73+
sys.stdout.write("Coverage is at 100%")
7374
return 0
7475

7576

0 commit comments

Comments
 (0)