From 8692561b0642ad6bf6a5eb6ef4eba5519126e6e8 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 14 Feb 2024 09:32:32 +0200 Subject: [PATCH 1/4] Ensure no warnings are found in the NEWS file before a given line number --- .github/workflows/reusable-docs.yml | 3 ++- Doc/tools/check-warnings.py | 40 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) 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 From 2ff144feff79932fa06de50080d3933293c07578 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 20 May 2024 10:01:17 -0400 Subject: [PATCH 2/4] TEMP news nit --- .../Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst b/Misc/NEWS.d/next/Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst index bfec178f6318a7..5dc8779184a16b 100644 --- a/Misc/NEWS.d/next/Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst +++ b/Misc/NEWS.d/next/Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst @@ -1,2 +1,2 @@ -Fixes creation of ACLs in :func:`os.mkdir` on Windows to work correctly on +Fixes creation of ACLs in :func:`os.mkdir`` on Windows to work correctly on non-English machines. From 3aebebe282e538b9a2f7eac47651630c854b9d6c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 20 May 2024 10:47:50 -0400 Subject: [PATCH 3/4] Fix news warnings --- .../2024-05-07-16-57-56.gh-issue-118561.wNMKVd.rst | 4 ++-- .../Library/2023-04-10-00-04-37.gh-issue-87106.UyBnPQ.rst | 2 +- .../Library/2024-05-08-19-47-34.gh-issue-101357.e4R_9x.rst | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-05-07-16-57-56.gh-issue-118561.wNMKVd.rst b/Misc/NEWS.d/next/Core and Builtins/2024-05-07-16-57-56.gh-issue-118561.wNMKVd.rst index 9eaf0abb8a6128..c506a8cefd00f1 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2024-05-07-16-57-56.gh-issue-118561.wNMKVd.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2024-05-07-16-57-56.gh-issue-118561.wNMKVd.rst @@ -1,2 +1,2 @@ -Fix race condition in free-threaded build where :meth:`list.extend` could expose -uninitialied memory to concurrent readers. +Fix race condition in free-threaded build where :meth:`!list.extend` could +expose uninitialised memory to concurrent readers. 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-05-08-19-47-34.gh-issue-101357.e4R_9x.rst b/Misc/NEWS.d/next/Library/2024-05-08-19-47-34.gh-issue-101357.e4R_9x.rst index 9fad7a416fcc24..c99a7e5f024823 100644 --- a/Misc/NEWS.d/next/Library/2024-05-08-19-47-34.gh-issue-101357.e4R_9x.rst +++ b/Misc/NEWS.d/next/Library/2024-05-08-19-47-34.gh-issue-101357.e4R_9x.rst @@ -1,5 +1,5 @@ Suppress all :exc:`OSError` exceptions from :meth:`pathlib.Path.exists` and ``is_*()`` methods, rather than a selection of more common errors. The new behaviour is consistent with :func:`os.path.exists`, :func:`os.path.isdir`, -etc. Use :meth:`Path.stat` to retrieve the file status without suppressing -exceptions. +etc. Use :meth:`pathlib.Path.stat` to retrieve the file status without +suppressing exceptions. From 6a835f9c4bb8fa2a350984a34f63ef6b3ebba822 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 20 May 2024 14:26:35 -0400 Subject: [PATCH 4/4] Revert "TEMP news nit" This reverts commit 2ff144feff79932fa06de50080d3933293c07578. --- .../Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst b/Misc/NEWS.d/next/Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst index 5dc8779184a16b..bfec178f6318a7 100644 --- a/Misc/NEWS.d/next/Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst +++ b/Misc/NEWS.d/next/Security/2024-05-08-21-59-38.gh-issue-118773.7dFRJY.rst @@ -1,2 +1,2 @@ -Fixes creation of ACLs in :func:`os.mkdir`` on Windows to work correctly on +Fixes creation of ACLs in :func:`os.mkdir` on Windows to work correctly on non-English machines.