diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 39d38ac327..380380d74e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,12 +33,6 @@ repos: args: ["--notice=script/copyright.txt", "--enforce-all"] exclude: tests(/\w*)*/functional/|tests/input|doc/data/messages|examples/|setup.py|tests(/\w*)*data/ types: [python] - - repo: https://github.com/asottile/pyupgrade - rev: v3.13.0 - hooks: - - id: pyupgrade - args: [--py38-plus] - exclude: *fixtures - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: diff --git a/pylint/checkers/base_checker.py b/pylint/checkers/base_checker.py index f6b8822b81..3f153364ea 100644 --- a/pylint/checkers/base_checker.py +++ b/pylint/checkers/base_checker.py @@ -134,8 +134,8 @@ def get_full_documentation( if reports: result += get_rst_title(f"{checker_title} Reports", "^") for report in reports: - result += ( - ":%s: %s\n" % report[:2] # pylint: disable=consider-using-f-string + result += ":{}: {}\n".format( # pylint: disable=consider-using-f-string + *report[:2] ) result += "\n" result += "\n" diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py index 428d44c6fa..d29326693a 100644 --- a/pylint/checkers/refactoring/refactoring_checker.py +++ b/pylint/checkers/refactoring/refactoring_checker.py @@ -914,15 +914,15 @@ def _check_consider_using_min_max_builtin(self, node: nodes.If) -> None: return if operator in {"<", "<="}: - reduced_to = "{target} = max({target}, {item})".format( - target=target_assignation, item=body_value + reduced_to = ( + f"{target_assignation} = max({target_assignation}, {body_value})" ) self.add_message( "consider-using-max-builtin", node=node, args=(reduced_to,) ) elif operator in {">", ">="}: - reduced_to = "{target} = min({target}, {item})".format( - target=target_assignation, item=body_value + reduced_to = ( + f"{target_assignation} = min({target_assignation}, {body_value})" ) self.add_message( "consider-using-min-builtin", node=node, args=(reduced_to,) diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py index 675cb93870..9b4b3e0db6 100644 --- a/pylint/extensions/_check_docs_utils.py +++ b/pylint/extensions/_check_docs_utils.py @@ -347,12 +347,10 @@ class SphinxDocstring(Docstring): [\(\[] [^\n\s]+ [\)\]] # with the contents of the container """ - re_multiple_simple_type = r""" - (?:{container_type}|{type}) - (?:(?:\s+(?:of|or)\s+|\s*,\s*|\s+\|\s+)(?:{container_type}|{type}))* - """.format( - type=re_type, container_type=re_simple_container_type - ) + re_multiple_simple_type = rf""" + (?:{re_simple_container_type}|{re_type}) + (?:(?:\s+(?:of|or)\s+|\s*,\s*|\s+\|\s+)(?:{re_simple_container_type}|{re_type}))* + """ re_xref = rf""" (?::\w+:)? # optional tag @@ -549,12 +547,10 @@ class GoogleDocstring(Docstring): [\(\[] [^\n]+ [\)\]] # with the contents of the container """ - re_multiple_type = r""" - (?:{container_type}|{type}|{xref}) - (?:(?:\s+(?:of|or)\s+|\s*,\s*|\s+\|\s+)(?:{container_type}|{type}|{xref}))* - """.format( - type=re_type, xref=re_xref, container_type=re_container_type - ) + re_multiple_type = rf""" + (?:{re_container_type}|{re_type}|{re_xref}) + (?:(?:\s+(?:of|or)\s+|\s*,\s*|\s+\|\s+)(?:{re_container_type}|{re_type}|{re_xref}))* + """ _re_section_template = r""" ^([ ]*) {0} \s*: \s*$ # Google parameter header diff --git a/pylint/testutils/constants.py b/pylint/testutils/constants.py index 0d93b7e876..956b44096b 100644 --- a/pylint/testutils/constants.py +++ b/pylint/testutils/constants.py @@ -23,7 +23,7 @@ _EXPECTED_RE = re.compile( r"\s*#\s*(?:(?P[+-]?[0-9]+):)?" # pylint: disable=consider-using-f-string r"(?:(?P[><=]+) *(?P[0-9.]+):)?" - r"\s*\[(?P%(msg)s(?:,\s*%(msg)s)*)]" % _MESSAGE + r"\s*\[(?P{msg}(?:,\s*{msg})*)]".format(**_MESSAGE) ) _OPERATORS = {">": operator.gt, "<": operator.lt, ">=": operator.ge, "<=": operator.le} diff --git a/pyproject.toml b/pyproject.toml index a8efe1e096..7e9ef35336 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -151,6 +151,7 @@ select = [ "B", # bugbear "I", # isort "RUF", # ruff + "UP", # pyupgrade ] ignore = [ @@ -165,4 +166,5 @@ fixable = [ "B", # bugbear "I", # isort "RUF", # ruff + "UP", # pyupgrade ]