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

Skip to content

Commit efc4e78

Browse files
committed
update
1 parent 76a97e6 commit efc4e78

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

.github/workflows/mypy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ jobs:
8686
# Pyright reports different percentages on different platforms
8787
if: runner.os == 'Linux'
8888
run: |
89-
spin run python tools/pyright_cov.py --verifytypes numpy --ignoreexternal --fail-under 80 --exclude-like '*.tests.*'
89+
spin run python tools/pyright_completeness.py --verifytypes numpy --ignoreexternal --exclude-like '*.tests.*' '*.conftest.*'

numpy/typing/mypy_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ def _get_c_intp_name() -> str:
108108
from mypy.nodes import ImportFrom, MypyFile, Statement
109109
from mypy.plugin import AnalyzeTypeContext, Plugin
110110

111-
except ModuleNotFoundError as e:
111+
except ModuleNotFoundError as _exc:
112112

113113
def plugin(version: str) -> type:
114-
raise e
114+
raise _exc
115115

116116
else:
117117

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
55
Example usage:
66
7-
spin run python tools/pyright_cov.py --verifytypes numpy --ignoreexternal \
8-
--fail-under 80 --exclude-like '*.tests.*'
7+
spin run python tools/pyright_completeness.py --verifytypes numpy --ignoreexternal \
8+
--fail-under 80 --exclude-like '*.tests.*' '*.conftest.*'
99
1010
We use `--ignoreexternal` to avoid "partially unknown" reports coming from the stdlib
1111
`numbers` module, see https://github.com/microsoft/pyright/discussions/9911.
12-
13-
It might be possible to replace this with `basedpyright`
14-
https://github.com/DetachHead/basedpyright/issues/125 in the future.
1512
"""
1613
from __future__ import annotations
1714

@@ -34,6 +31,7 @@ def main(argv: Sequence[str] | None = None) -> int:
3431
parser.add_argument(
3532
"--exclude-like",
3633
required=False,
34+
nargs='*',
3735
type=str,
3836
help="Exclude symbols whose names matches this glob pattern",
3937
)
@@ -47,7 +45,7 @@ def main(argv: Sequence[str] | None = None) -> int:
4745
def run_pyright_with_coverage(
4846
pyright_args: list[str],
4947
cov_fail_under: float,
50-
exclude_like: str | None,
48+
exclude_like: Sequence[str],
5149
) -> int:
5250
result = subprocess.run(
5351
["pyright", *pyright_args], capture_output=True, text=True
@@ -60,10 +58,10 @@ def run_pyright_with_coverage(
6058
sys.stderr.write(result.stderr)
6159
return 1
6260

63-
if exclude_like is not None:
61+
if exclude_like:
6462
symbols = data["typeCompleteness"]["symbols"]
6563
matched_symbols = [
66-
x for x in symbols if not fnmatch.fnmatch(x["name"], exclude_like)
64+
x for x in symbols if not any(fnmatch.fnmatch(x["name"], pattern) for pattern in exclude_like)
6765
and x['isExported']
6866
]
6967
cov_percent = (
@@ -73,16 +71,15 @@ def run_pyright_with_coverage(
7371
cov_percent = data["typeCompleteness"]["completenessScore"] * 100
7472

7573
sys.stderr.write(result.stderr)
76-
sys.stdout.write(result.stdout)
7774
if cov_percent < cov_fail_under:
7875
sys.stdout.write(
7976
f"Coverage {cov_percent:.1f}% is below minimum required "
80-
f"{cov_fail_under:.1f}%"
77+
f"{cov_fail_under:.1f}%\n"
8178
)
8279
return 1
8380
sys.stdout.write(
8481
f"Coverage {cov_percent:.1f}% is at or above minimum required "
85-
f"{cov_fail_under:.1f}%"
82+
f"{cov_fail_under:.1f}%\n"
8683
)
8784
return 0
8885

0 commit comments

Comments
 (0)