https://github.com/python/cpython/commit/22bef9623737a785c145971fa8737db19484727f
commit: 22bef9623737a785c145971fa8737db19484727f
branch: 3.12
author: Hugo van Kemenade <[email protected]>
committer: hugovk <[email protected]>
date: 2024-05-21T08:40:16-06:00
summary:

[3.12] Docs: Ensure no warnings are found in the NEWS file before a given line 
number (GH-119221) (#119266)

files:
M .github/workflows/reusable-docs.yml
M Doc/tools/check-warnings.py
M Misc/NEWS.d/next/Library/2023-04-10-00-04-37.gh-issue-87106.UyBnPQ.rst
M Misc/NEWS.d/next/Library/2024-04-17-18-00-30.gh-issue-80361.RstWg-.rst
M Misc/NEWS.d/next/Library/2024-04-24-12-20-48.gh-issue-118013.TKn_kZ.rst
M Misc/NEWS.d/next/Library/2024-04-24-12-29-33.gh-issue-118221.2k_bac.rst
M Misc/NEWS.d/next/Library/2024-04-25-12-02-06.gh-issue-118042.2EcdHf.rst

diff --git a/.github/workflows/reusable-docs.yml 
b/.github/workflows/reusable-docs.yml
index 9e26d7847d2bd3..859f78d043ba92 100644
--- a/.github/workflows/reusable-docs.yml
+++ b/.github/workflows/reusable-docs.yml
@@ -62,7 +62,8 @@ jobs:
         python Doc/tools/check-warnings.py \
           --annotate-diff '${{ env.branch_base }}' '${{ env.branch_pr }}' \
           --fail-if-regression \
-          --fail-if-improved
+          --fail-if-improved \
+          --fail-if-new-news-nit
 
   # This build doesn't use problem matchers or check annotations
   build_doc_oldest_supported_sphinx:
diff --git a/Doc/tools/check-warnings.py b/Doc/tools/check-warnings.py
index 809a8d63087e12..c50b00636c36ce 100644
--- a/Doc/tools/check-warnings.py
+++ b/Doc/tools/check-warnings.py
@@ -13,6 +13,9 @@
 from pathlib import Path
 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,
 # because they trigger a rebuild of dirty files.
 EXCLUDE_FILES = {
@@ -245,6 +248,32 @@ def fail_if_improved(
     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:
     parser = argparse.ArgumentParser()
     parser.add_argument(
@@ -264,6 +293,14 @@ def main(argv: list[str] | None = None) -> int:
         action="store_true",
         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)
     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:
         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
 
 
diff --git 
a/Misc/NEWS.d/next/Library/2023-04-10-00-04-37.gh-issue-87106.UyBnPQ.rst 
b/Misc/NEWS.d/next/Library/2023-04-10-00-04-37.gh-issue-87106.UyBnPQ.rst
index 6f13188f6f119f..2c736e72476313 100644
--- a/Misc/NEWS.d/next/Library/2023-04-10-00-04-37.gh-issue-87106.UyBnPQ.rst
+++ b/Misc/NEWS.d/next/Library/2023-04-10-00-04-37.gh-issue-87106.UyBnPQ.rst
@@ -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
 (e.g. ``**kwargs``) is present.
diff --git 
a/Misc/NEWS.d/next/Library/2024-04-17-18-00-30.gh-issue-80361.RstWg-.rst 
b/Misc/NEWS.d/next/Library/2024-04-17-18-00-30.gh-issue-80361.RstWg-.rst
index 3bbae23cc18bf6..ce6e19565a4070 100644
--- a/Misc/NEWS.d/next/Library/2024-04-17-18-00-30.gh-issue-80361.RstWg-.rst
+++ b/Misc/NEWS.d/next/Library/2024-04-17-18-00-30.gh-issue-80361.RstWg-.rst
@@ -1,2 +1,2 @@
-Fix TypeError in :func:`email.Message.get_payload` when the charset is 
:rfc:`2231`
-encoded.
+Fix TypeError in :func:`email.message.Message.get_payload` when the charset is
+:rfc:`2231` encoded.
diff --git 
a/Misc/NEWS.d/next/Library/2024-04-24-12-20-48.gh-issue-118013.TKn_kZ.rst 
b/Misc/NEWS.d/next/Library/2024-04-24-12-20-48.gh-issue-118013.TKn_kZ.rst
index 8eb68ebe99ba15..aa2da4f837bb6c 100644
--- a/Misc/NEWS.d/next/Library/2024-04-24-12-20-48.gh-issue-118013.TKn_kZ.rst
+++ b/Misc/NEWS.d/next/Library/2024-04-24-12-20-48.gh-issue-118013.TKn_kZ.rst
@@ -5,5 +5,5 @@ to that instance's class to persist in an internal cache in the
 class was dynamically created, the class held strong references to other
 objects which took up a significant amount of memory, and the cache
 contained the sole strong reference to the class. The fix for the regression
-leads to a slowdown in :func:`getattr_static`, but the function should still
-be signficantly faster than it was in Python 3.11. Patch by Alex Waygood.
+leads to a slowdown in :func:`!getattr_static`, but the function should still
+be significantly faster than it was in Python 3.11. Patch by Alex Waygood.
diff --git 
a/Misc/NEWS.d/next/Library/2024-04-24-12-29-33.gh-issue-118221.2k_bac.rst 
b/Misc/NEWS.d/next/Library/2024-04-24-12-29-33.gh-issue-118221.2k_bac.rst
index 9b0ea9978a195e..94867b43e68eb3 100644
--- a/Misc/NEWS.d/next/Library/2024-04-24-12-29-33.gh-issue-118221.2k_bac.rst
+++ b/Misc/NEWS.d/next/Library/2024-04-24-12-29-33.gh-issue-118221.2k_bac.rst
@@ -1,2 +1,2 @@
-Fix a bug where :func:`sqlite3.iterdump` could fail if a custom :attr:`row
+Fix a bug where :func:`!sqlite3.iterdump` could fail if a custom :attr:`row
 factory <sqlite3.Connection.row_factory>` was used. Patch by Erlend Aasland.
diff --git 
a/Misc/NEWS.d/next/Library/2024-04-25-12-02-06.gh-issue-118042.2EcdHf.rst 
b/Misc/NEWS.d/next/Library/2024-04-25-12-02-06.gh-issue-118042.2EcdHf.rst
index 7337aae0981ef5..5ef2cd545952e1 100644
--- a/Misc/NEWS.d/next/Library/2024-04-25-12-02-06.gh-issue-118042.2EcdHf.rst
+++ b/Misc/NEWS.d/next/Library/2024-04-25-12-02-06.gh-issue-118042.2EcdHf.rst
@@ -1,2 +1,2 @@
-Fix an unraisable exception in :meth:`telnetlib.Telnet.__del__` when the
+Fix an unraisable exception in :meth:`!telnetlib.Telnet.__del__` when the
 ``__init__()`` method was not called.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to