mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Docs: Ensure no warnings are found in the NEWS file before a given line number (#119221)
This commit is contained in:
parent
e188527c34
commit
034cf0c316
5 changed files with 47 additions and 6 deletions
3
.github/workflows/reusable-docs.yml
vendored
3
.github/workflows/reusable-docs.yml
vendored
|
@ -62,7 +62,8 @@ jobs:
|
||||||
python Doc/tools/check-warnings.py \
|
python Doc/tools/check-warnings.py \
|
||||||
--annotate-diff '${{ env.branch_base }}' '${{ env.branch_pr }}' \
|
--annotate-diff '${{ env.branch_base }}' '${{ env.branch_pr }}' \
|
||||||
--fail-if-regression \
|
--fail-if-regression \
|
||||||
--fail-if-improved
|
--fail-if-improved \
|
||||||
|
--fail-if-new-news-nit
|
||||||
|
|
||||||
# This build doesn't use problem matchers or check annotations
|
# This build doesn't use problem matchers or check annotations
|
||||||
build_doc_oldest_supported_sphinx:
|
build_doc_oldest_supported_sphinx:
|
||||||
|
|
|
@ -13,6 +13,9 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TextIO
|
from typing import TextIO
|
||||||
|
|
||||||
|
# Fail if NEWS nit found before this line number
|
||||||
|
NEWS_NIT_THRESHOLD = 200
|
||||||
|
|
||||||
# Exclude these whether they're dirty or clean,
|
# Exclude these whether they're dirty or clean,
|
||||||
# because they trigger a rebuild of dirty files.
|
# because they trigger a rebuild of dirty files.
|
||||||
EXCLUDE_FILES = {
|
EXCLUDE_FILES = {
|
||||||
|
@ -245,6 +248,32 @@ def fail_if_improved(
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def fail_if_new_news_nit(warnings: list[str], threshold: int) -> int:
|
||||||
|
"""
|
||||||
|
Ensure no warnings are found in the NEWS file before a given line number.
|
||||||
|
"""
|
||||||
|
news_nits = (
|
||||||
|
warning
|
||||||
|
for warning in warnings
|
||||||
|
if "/build/NEWS:" in warning
|
||||||
|
)
|
||||||
|
|
||||||
|
# Nits found before the threshold line
|
||||||
|
new_news_nits = [
|
||||||
|
nit
|
||||||
|
for nit in news_nits
|
||||||
|
if int(nit.split(":")[1]) <= threshold
|
||||||
|
]
|
||||||
|
|
||||||
|
if new_news_nits:
|
||||||
|
print("\nError: new NEWS nits:\n")
|
||||||
|
for warning in new_news_nits:
|
||||||
|
print(warning)
|
||||||
|
return -1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def main(argv: list[str] | None = None) -> int:
|
def main(argv: list[str] | None = None) -> int:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -264,6 +293,14 @@ def main(argv: list[str] | None = None) -> int:
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Fail if new files with no nits are found",
|
help="Fail if new files with no nits are found",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--fail-if-new-news-nit",
|
||||||
|
metavar="threshold",
|
||||||
|
type=int,
|
||||||
|
nargs="?",
|
||||||
|
const=NEWS_NIT_THRESHOLD,
|
||||||
|
help="Fail if new NEWS nit found before threshold line number",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
if args.annotate_diff is not None and len(args.annotate_diff) > 2:
|
if args.annotate_diff is not None and len(args.annotate_diff) > 2:
|
||||||
|
@ -304,6 +341,9 @@ def main(argv: list[str] | None = None) -> int:
|
||||||
if args.fail_if_improved:
|
if args.fail_if_improved:
|
||||||
exit_code += fail_if_improved(files_with_expected_nits, files_with_nits)
|
exit_code += fail_if_improved(files_with_expected_nits, files_with_nits)
|
||||||
|
|
||||||
|
if args.fail_if_new_news_nit:
|
||||||
|
exit_code += fail_if_new_news_nit(warnings, args.fail_if_new_news_nit)
|
||||||
|
|
||||||
return exit_code
|
return exit_code
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
Fix race condition in free-threaded build where :meth:`list.extend` could expose
|
Fix race condition in free-threaded build where :meth:`!list.extend` could
|
||||||
uninitialied memory to concurrent readers.
|
expose uninitialised memory to concurrent readers.
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Fixed handling in :meth:`inspect.signature.bind` of keyword arguments having
|
Fixed handling in :meth:`inspect.Signature.bind` of keyword arguments having
|
||||||
the same name as positional-only arguments when a variadic keyword argument
|
the same name as positional-only arguments when a variadic keyword argument
|
||||||
(e.g. ``**kwargs``) is present.
|
(e.g. ``**kwargs``) is present.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Suppress all :exc:`OSError` exceptions from :meth:`pathlib.Path.exists` and
|
Suppress all :exc:`OSError` exceptions from :meth:`pathlib.Path.exists` and
|
||||||
``is_*()`` methods, rather than a selection of more common errors. The new
|
``is_*()`` methods, rather than a selection of more common errors. The new
|
||||||
behaviour is consistent with :func:`os.path.exists`, :func:`os.path.isdir`,
|
behaviour is consistent with :func:`os.path.exists`, :func:`os.path.isdir`,
|
||||||
etc. Use :meth:`Path.stat` to retrieve the file status without suppressing
|
etc. Use :meth:`pathlib.Path.stat` to retrieve the file status without
|
||||||
exceptions.
|
suppressing exceptions.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue