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

Skip to content

Commit 22bef96

Browse files
authored
[3.12] Docs: Ensure no warnings are found in the NEWS file before a given line number (GH-119221) (#119266)
1 parent 8b6175c commit 22bef96

7 files changed

+49
-8
lines changed

.github/workflows/reusable-docs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ jobs:
6262
python Doc/tools/check-warnings.py \
6363
--annotate-diff '${{ env.branch_base }}' '${{ env.branch_pr }}' \
6464
--fail-if-regression \
65-
--fail-if-improved
65+
--fail-if-improved \
66+
--fail-if-new-news-nit
6667
6768
# This build doesn't use problem matchers or check annotations
6869
build_doc_oldest_supported_sphinx:

Doc/tools/check-warnings.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from pathlib import Path
1414
from typing import TextIO
1515

16+
# Fail if NEWS nit found before this line number
17+
NEWS_NIT_THRESHOLD = 200
18+
1619
# Exclude these whether they're dirty or clean,
1720
# because they trigger a rebuild of dirty files.
1821
EXCLUDE_FILES = {
@@ -245,6 +248,32 @@ def fail_if_improved(
245248
return 0
246249

247250

251+
def fail_if_new_news_nit(warnings: list[str], threshold: int) -> int:
252+
"""
253+
Ensure no warnings are found in the NEWS file before a given line number.
254+
"""
255+
news_nits = (
256+
warning
257+
for warning in warnings
258+
if "/build/NEWS:" in warning
259+
)
260+
261+
# Nits found before the threshold line
262+
new_news_nits = [
263+
nit
264+
for nit in news_nits
265+
if int(nit.split(":")[1]) <= threshold
266+
]
267+
268+
if new_news_nits:
269+
print("\nError: new NEWS nits:\n")
270+
for warning in new_news_nits:
271+
print(warning)
272+
return -1
273+
274+
return 0
275+
276+
248277
def main(argv: list[str] | None = None) -> int:
249278
parser = argparse.ArgumentParser()
250279
parser.add_argument(
@@ -264,6 +293,14 @@ def main(argv: list[str] | None = None) -> int:
264293
action="store_true",
265294
help="Fail if new files with no nits are found",
266295
)
296+
parser.add_argument(
297+
"--fail-if-new-news-nit",
298+
metavar="threshold",
299+
type=int,
300+
nargs="?",
301+
const=NEWS_NIT_THRESHOLD,
302+
help="Fail if new NEWS nit found before threshold line number",
303+
)
267304

268305
args = parser.parse_args(argv)
269306
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:
304341
if args.fail_if_improved:
305342
exit_code += fail_if_improved(files_with_expected_nits, files_with_nits)
306343

344+
if args.fail_if_new_news_nit:
345+
exit_code += fail_if_new_news_nit(warnings, args.fail_if_new_news_nit)
346+
307347
return exit_code
308348

309349

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Fixed handling in :meth:`inspect.signature.bind` of keyword arguments having
1+
Fixed handling in :meth:`inspect.Signature.bind` of keyword arguments having
22
the same name as positional-only arguments when a variadic keyword argument
33
(e.g. ``**kwargs``) is present.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Fix TypeError in :func:`email.Message.get_payload` when the charset is :rfc:`2231`
2-
encoded.
1+
Fix TypeError in :func:`email.message.Message.get_payload` when the charset is
2+
:rfc:`2231` encoded.

Misc/NEWS.d/next/Library/2024-04-24-12-20-48.gh-issue-118013.TKn_kZ.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ to that instance's class to persist in an internal cache in the
55
class was dynamically created, the class held strong references to other
66
objects which took up a significant amount of memory, and the cache
77
contained the sole strong reference to the class. The fix for the regression
8-
leads to a slowdown in :func:`getattr_static`, but the function should still
9-
be signficantly faster than it was in Python 3.11. Patch by Alex Waygood.
8+
leads to a slowdown in :func:`!getattr_static`, but the function should still
9+
be significantly faster than it was in Python 3.11. Patch by Alex Waygood.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Fix a bug where :func:`sqlite3.iterdump` could fail if a custom :attr:`row
1+
Fix a bug where :func:`!sqlite3.iterdump` could fail if a custom :attr:`row
22
factory <sqlite3.Connection.row_factory>` was used. Patch by Erlend Aasland.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Fix an unraisable exception in :meth:`telnetlib.Telnet.__del__` when the
1+
Fix an unraisable exception in :meth:`!telnetlib.Telnet.__del__` when the
22
``__init__()`` method was not called.

0 commit comments

Comments
 (0)