diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/__init__.py | 4 | ||||
-rw-r--r-- | script/bump_changelog.py | 4 | ||||
-rw-r--r-- | script/check_newsfragments.py | 7 | ||||
-rw-r--r-- | script/copyright.txt | 4 | ||||
-rw-r--r-- | script/create_contributor_list.py | 4 | ||||
-rw-r--r-- | script/fix_documentation.py | 103 | ||||
-rw-r--r-- | script/get_unused_message_id_category.py | 5 |
7 files changed, 14 insertions, 117 deletions
diff --git a/script/__init__.py b/script/__init__.py index e8a8ff79f..cfd18ddd3 100644 --- a/script/__init__.py +++ b/script/__init__.py @@ -1,3 +1,3 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt diff --git a/script/bump_changelog.py b/script/bump_changelog.py index 0963c7c60..3c04c4be5 100644 --- a/script/bump_changelog.py +++ b/script/bump_changelog.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """This script updates towncrier.toml and creates a new newsfile and intermediate folders if necessary. diff --git a/script/check_newsfragments.py b/script/check_newsfragments.py index b840d9da0..f5069a4bb 100644 --- a/script/check_newsfragments.py +++ b/script/check_newsfragments.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Small script to check the formatting of news fragments for towncrier. Used by pre-commit. @@ -34,12 +34,13 @@ VALID_FILE_TYPE = frozenset( "bugfix", "other", "internal", + "performance", ] ) ISSUES_KEYWORDS = "|".join(VALID_ISSUES_KEYWORDS) VALID_CHANGELOG_PATTERN = ( rf"(?P<description>(.*\n)*(.*\.\n))\n(?P<ref>({ISSUES_KEYWORDS})" - r" (PyCQA/astroid)?#(?P<issue>\d+))" + r" (pylint-dev/astroid)?#(?P<issue>\d+))" ) VALID_CHANGELOG_COMPILED_PATTERN: Pattern[str] = re.compile( VALID_CHANGELOG_PATTERN, flags=re.MULTILINE diff --git a/script/copyright.txt b/script/copyright.txt index e8a8ff79f..cfd18ddd3 100644 --- a/script/copyright.txt +++ b/script/copyright.txt @@ -1,3 +1,3 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt diff --git a/script/create_contributor_list.py b/script/create_contributor_list.py index 4502f824d..656902e91 100644 --- a/script/create_contributor_list.py +++ b/script/create_contributor_list.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt from pathlib import Path diff --git a/script/fix_documentation.py b/script/fix_documentation.py deleted file mode 100644 index e8def2f73..000000000 --- a/script/fix_documentation.py +++ /dev/null @@ -1,103 +0,0 @@ -# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt - -"""Small script to fix various issues with the documentation. Used by pre-commit.""" - -from __future__ import annotations - -import argparse -import re -import sys - -INVALID_CODE_BLOCK_PATTERN = ( - r"(?<=\s`)([\w\-\.\(\)\=]+\s{0,1}[\w\-\.\(\)\=]*)(?=`[,\.]{0,1}\s|$)" -) - -# TODO: 2.16.0: Upgrade script for change in changelog -DEFAULT_CHANGELOG = "ChangeLog" -DEFAULT_SUBTITLE_PREFIX = "What's New in" - - -def fix_inline_code_blocks(file_content: str) -> str: - """Use double quotes for code blocks. RST style. - - Example: - `hello-world` -> ``hello-world`` - """ - pattern = re.compile(INVALID_CODE_BLOCK_PATTERN) - return pattern.sub(r"`\g<0>`", file_content) - - -def changelog_insert_empty_lines(file_content: str, subtitle_text: str) -> str: - """Insert up to two empty lines before `What's New` entry in ChangeLog.""" - lines = file_content.split("\n") - subtitle_count = 0 - for i, line in enumerate(lines): - if line.startswith(subtitle_text): - subtitle_count += 1 - if subtitle_count == 1 or i < 2 or not lines[i - 1] and not lines[i - 2]: - continue - lines.insert(i, "") - return "\n".join(lines) - - -class CustomHelpFormatter(argparse.HelpFormatter): - def __init__( - self, - prog: str, - indent_increment: int = 2, - max_help_position: int = 24, - width: int | None = None, - ) -> None: - max_help_position = 40 - super().__init__( - prog, - indent_increment=indent_increment, - max_help_position=max_help_position, - width=width, - ) - - -def main(argv: list[str] | None = None) -> int: - argv = argv or sys.argv[1:] - parser = argparse.ArgumentParser(formatter_class=CustomHelpFormatter) - parser.add_argument( - "--changelog", - metavar="file", - default=DEFAULT_CHANGELOG, - help="Changelog filename (default: '%(default)s')", - ) - parser.add_argument( - "--subtitle-prefix", - metavar="prefix", - default=DEFAULT_SUBTITLE_PREFIX, - help="Subtitle prefix (default: '%(default)s')", - ) - parser.add_argument( - "filenames", - nargs="*", - metavar="FILES", - help="File names to modify", - ) - args = parser.parse_args(argv) - - return_value: int = 0 - for file_name in args.filenames: - with open(file_name, encoding="utf-8") as fp: - original_content = fp.read() - content = original_content - # Modify files - content = fix_inline_code_blocks(content) - if file_name == args.changelog: - content = changelog_insert_empty_lines(content, args.subtitle_prefix) - # If modified, write changes and eventually return 1 - if original_content != content: - with open(file_name, "w", encoding="utf-8") as fp: - fp.write(content) - return_value |= 1 - return return_value - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/script/get_unused_message_id_category.py b/script/get_unused_message_id_category.py index 4ea8390ee..0e0e67d68 100644 --- a/script/get_unused_message_id_category.py +++ b/script/get_unused_message_id_category.py @@ -1,7 +1,7 @@ """Small script to get a new unused message id category.""" # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt from __future__ import annotations @@ -13,7 +13,6 @@ from pylint.message._deleted_message_ids import DELETED_MSGID_PREFIXES def register_all_checkers_and_plugins(linter: PyLinter) -> None: """Registers all checkers and plugins.""" - linter.cmdline_parser.set_conflict_handler("resolve") initialize_checkers(linter) initialize_extensions(linter) |