mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-133403: Run mypy on Tools/build/check_warnings.py (#137700)
Some checks failed
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
Tests / Windows MSI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
JIT / Interpreter (Debug) (push) Has been cancelled
JIT / aarch64-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / aarch64-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / i686-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / i686-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / aarch64-apple-darwin/clang (Release) (push) Has been cancelled
JIT / aarch64-unknown-linux-gnu/gcc (Release) (push) Has been cancelled
JIT / aarch64-apple-darwin/clang (Debug) (push) Has been cancelled
JIT / aarch64-unknown-linux-gnu/gcc (Debug) (push) Has been cancelled
JIT / x86_64-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / x86_64-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / x86_64-apple-darwin/clang (Release) (push) Has been cancelled
JIT / x86_64-unknown-linux-gnu/gcc (Release) (push) Has been cancelled
JIT / x86_64-apple-darwin/clang (Debug) (push) Has been cancelled
JIT / x86_64-unknown-linux-gnu/gcc (Debug) (push) Has been cancelled
Some checks failed
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
Tests / Windows MSI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
JIT / Interpreter (Debug) (push) Has been cancelled
JIT / aarch64-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / aarch64-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / i686-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / i686-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / aarch64-apple-darwin/clang (Release) (push) Has been cancelled
JIT / aarch64-unknown-linux-gnu/gcc (Release) (push) Has been cancelled
JIT / aarch64-apple-darwin/clang (Debug) (push) Has been cancelled
JIT / aarch64-unknown-linux-gnu/gcc (Debug) (push) Has been cancelled
JIT / x86_64-pc-windows-msvc/msvc (Release) (push) Has been cancelled
JIT / x86_64-pc-windows-msvc/msvc (Debug) (push) Has been cancelled
JIT / x86_64-apple-darwin/clang (Release) (push) Has been cancelled
JIT / x86_64-unknown-linux-gnu/gcc (Release) (push) Has been cancelled
JIT / x86_64-apple-darwin/clang (Debug) (push) Has been cancelled
JIT / x86_64-unknown-linux-gnu/gcc (Debug) (push) Has been cancelled
This commit is contained in:
parent
c87b66bc7c
commit
04377a1bd1
3 changed files with 29 additions and 13 deletions
9
.github/workflows/mypy.yml
vendored
9
.github/workflows/mypy.yml
vendored
|
|
@ -13,16 +13,17 @@ on:
|
|||
- "Lib/test/libregrtest/**"
|
||||
- "Lib/tomllib/**"
|
||||
- "Misc/mypy/**"
|
||||
- "Tools/build/mypy.ini"
|
||||
- "Tools/build/check_extension_modules.py"
|
||||
- "Tools/build/check_warnings.py"
|
||||
- "Tools/build/compute-changes.py"
|
||||
- "Tools/build/deepfreeze.py"
|
||||
- "Tools/build/generate-build-details.py"
|
||||
- "Tools/build/generate_sbom.py"
|
||||
- "Tools/build/generate_stdlib_module_names.py"
|
||||
- "Tools/build/generate-build-details.py"
|
||||
- "Tools/build/verify_ensurepip_wheels.py"
|
||||
- "Tools/build/update_file.py"
|
||||
- "Tools/build/mypy.ini"
|
||||
- "Tools/build/umarshal.py"
|
||||
- "Tools/build/update_file.py"
|
||||
- "Tools/build/verify_ensurepip_wheels.py"
|
||||
- "Tools/cases_generator/**"
|
||||
- "Tools/clinic/**"
|
||||
- "Tools/jit/**"
|
||||
|
|
|
|||
|
|
@ -8,21 +8,29 @@ import re
|
|||
import sys
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple
|
||||
from typing import NamedTuple, TypedDict
|
||||
|
||||
|
||||
class IgnoreRule(NamedTuple):
|
||||
file_path: str
|
||||
count: int
|
||||
count: int # type: ignore[assignment]
|
||||
ignore_all: bool = False
|
||||
is_directory: bool = False
|
||||
|
||||
|
||||
class CompileWarning(TypedDict):
|
||||
file: str
|
||||
line: str
|
||||
column: str
|
||||
message: str
|
||||
option: str
|
||||
|
||||
|
||||
def parse_warning_ignore_file(file_path: str) -> set[IgnoreRule]:
|
||||
"""
|
||||
Parses the warning ignore file and returns a set of IgnoreRules
|
||||
"""
|
||||
files_with_expected_warnings = set()
|
||||
files_with_expected_warnings: set[IgnoreRule] = set()
|
||||
with Path(file_path).open(encoding="UTF-8") as ignore_rules_file:
|
||||
files_with_expected_warnings = set()
|
||||
for i, line in enumerate(ignore_rules_file):
|
||||
|
|
@ -46,7 +54,7 @@ def parse_warning_ignore_file(file_path: str) -> set[IgnoreRule]:
|
|||
)
|
||||
sys.exit(1)
|
||||
if ignore_all:
|
||||
count = 0
|
||||
count = "0"
|
||||
|
||||
files_with_expected_warnings.add(
|
||||
IgnoreRule(
|
||||
|
|
@ -61,7 +69,7 @@ def extract_warnings_from_compiler_output(
|
|||
compiler_output: str,
|
||||
compiler_output_type: str,
|
||||
path_prefix: str = "",
|
||||
) -> list[dict]:
|
||||
) -> list[CompileWarning]:
|
||||
"""
|
||||
Extracts warnings from the compiler output based on compiler
|
||||
output type. Removes path prefix from file paths if provided.
|
||||
|
|
@ -78,8 +86,12 @@ def extract_warnings_from_compiler_output(
|
|||
r"(?P<file>.*):(?P<line>\d+):(?P<column>\d+): warning: "
|
||||
r"(?P<message>.*) (?P<option>\[-[^\]]+\])$"
|
||||
)
|
||||
else:
|
||||
raise RuntimeError(
|
||||
f"Unsupported compiler output type: {compiler_output_type}",
|
||||
)
|
||||
compiled_regex = re.compile(regex_pattern)
|
||||
compiler_warnings = []
|
||||
compiler_warnings: list[CompileWarning] = []
|
||||
for i, line in enumerate(compiler_output.splitlines(), start=1):
|
||||
if match := compiled_regex.match(line):
|
||||
try:
|
||||
|
|
@ -100,7 +112,9 @@ def extract_warnings_from_compiler_output(
|
|||
return compiler_warnings
|
||||
|
||||
|
||||
def get_warnings_by_file(warnings: list[dict]) -> dict[str, list[dict]]:
|
||||
def get_warnings_by_file(
|
||||
warnings: list[CompileWarning],
|
||||
) -> dict[str, list[CompileWarning]]:
|
||||
"""
|
||||
Returns a dictionary where the key is the file and the data is the
|
||||
warnings in that file. Does not include duplicate warnings for a
|
||||
|
|
@ -138,7 +152,7 @@ def is_file_ignored(
|
|||
|
||||
def get_unexpected_warnings(
|
||||
ignore_rules: set[IgnoreRule],
|
||||
files_with_warnings: set[IgnoreRule],
|
||||
files_with_warnings: dict[str, list[CompileWarning]],
|
||||
) -> int:
|
||||
"""
|
||||
Returns failure status if warnings discovered in list of warnings
|
||||
|
|
@ -180,7 +194,7 @@ def get_unexpected_warnings(
|
|||
|
||||
def get_unexpected_improvements(
|
||||
ignore_rules: set[IgnoreRule],
|
||||
files_with_warnings: set[IgnoreRule],
|
||||
files_with_warnings: dict[str, list[CompileWarning]],
|
||||
) -> int:
|
||||
"""
|
||||
Returns failure status if the number of warnings for a file is greater
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
# .github/workflows/mypy.yml
|
||||
files =
|
||||
Tools/build/check_extension_modules.py,
|
||||
Tools/build/check_warnings.py,
|
||||
Tools/build/compute-changes.py,
|
||||
Tools/build/deepfreeze.py,
|
||||
Tools/build/generate-build-details.py,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue