summaryrefslogtreecommitdiff
path: root/tools/finalize.py
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-02-03 15:00:09 +0000
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-02-03 15:11:22 +0000
commite2a632576cd79a6d38a3f6f9f9ac348642e35230 (patch)
treea4eff38bc1b68481acc2bc70678179e7fb097041 /tools/finalize.py
parentdafb5e26955e48d59b8021835785e5d98ccd4f53 (diff)
downloadpython-setuptools-git-e2a632576cd79a6d38a3f6f9f9ac348642e35230.tar.gz
Modify tools.finalize.check_changes to validate extensions
The previous existing implementation would just check for the existence of a preconfigured substring (e.g. `changes`, `doc`, ...). However that can be problematic when the used extension contains one of the valid substrings but is not valid itself. For example `changelog.d/3034.docs.rst` contains the valid `doc` substring but is not a valid name itself. The correct would be `changelog.d/3034.doc.rst`.
Diffstat (limited to 'tools/finalize.py')
-rw-r--r--tools/finalize.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/finalize.py b/tools/finalize.py
index 516a2fb5..e4f65543 100644
--- a/tools/finalize.py
+++ b/tools/finalize.py
@@ -79,11 +79,18 @@ def check_changes():
"""
allowed = 'deprecation', 'breaking', 'change', 'doc', 'misc'
except_ = 'README.rst', '.gitignore'
- assert all(
- any(key in file.name for key in allowed)
+ news_fragments = (
+ file
for file in pathlib.Path('changelog.d').iterdir()
if file.name not in except_
)
+ unrecognized = [
+ str(file)
+ for file in news_fragments
+ if not any(f".{key}" in file.suffixes for key in allowed)
+ ]
+ if unrecognized:
+ raise ValueError(f"Some news fragments have invalid names: {unrecognized}")
if __name__ == '__main__':