From 07ca266a69a55f735114ec74fbae0a69db7bb347 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 13 Jul 2022 13:16:52 +0200 Subject: [PATCH] [cleanup] Remove '!r' on formatting of string and str call in fstring str's repr is the string, and you don't need a string call in a fstring. Follow-up to https://github.com/PyCQA/pylint/pull/7153#discussion_r918948296 --- pylint/checkers/imports.py | 2 +- pylint/config/arguments_provider.py | 2 +- pylint/config/options_provider_mixin.py | 4 +--- pylint/message/message_definition.py | 4 ++-- pylint/pyreverse/inspector.py | 2 +- tests/checkers/base/unittest_name_preset.py | 4 ++-- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index 97d9d51f6c..7dba21850b 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -767,7 +767,7 @@ def _get_imported_module(self, importnode, modname): return None self.add_message("relative-beyond-top-level", node=importnode) except astroid.AstroidSyntaxError as exc: - message = f"Cannot import {modname!r} due to syntax error {str(exc.error)!r}" # pylint: disable=no-member; false positive + message = f"Cannot import {modname!r} due to syntax error {exc.error!r}" # pylint: disable=no-member; false positive self.add_message("syntax-error", line=importnode.lineno, args=message) except astroid.AstroidBuildingError: diff --git a/pylint/config/arguments_provider.py b/pylint/config/arguments_provider.py index 2ab44b1614..3485084839 100644 --- a/pylint/config/arguments_provider.py +++ b/pylint/config/arguments_provider.py @@ -149,7 +149,7 @@ def get_option_def(self, opt: str) -> OptionDict: # pragma: no cover if option[0] == opt: return option[1] raise optparse.OptionError( - f"no such option {opt} in section {self.name!r}", opt # type: ignore[arg-type] + f"no such option {opt} in section {self.name}", opt # type: ignore[arg-type] ) def options_by_section( diff --git a/pylint/config/options_provider_mixin.py b/pylint/config/options_provider_mixin.py index 5b20a290fb..b03a5c8a7b 100644 --- a/pylint/config/options_provider_mixin.py +++ b/pylint/config/options_provider_mixin.py @@ -94,9 +94,7 @@ def get_option_def(self, opt): for option in self.options: if option[0] == opt: return option[1] - raise optparse.OptionError( - f"no such option {opt} in section {self.name!r}", opt - ) + raise optparse.OptionError(f"no such option {opt} in section {self.name}", opt) def options_by_section(self): """Return an iterator on options grouped by section. diff --git a/pylint/message/message_definition.py b/pylint/message/message_definition.py index 3b403b0082..23bfe98453 100644 --- a/pylint/message/message_definition.py +++ b/pylint/message/message_definition.py @@ -53,9 +53,9 @@ def __init__( @staticmethod def check_msgid(msgid: str) -> None: if len(msgid) != 5: - raise InvalidMessageError(f"Invalid message id {msgid!r}") + raise InvalidMessageError(f"Invalid message id {msgid}") if msgid[0] not in MSG_TYPES: - raise InvalidMessageError(f"Bad message type {msgid[0]} in {msgid!r}") + raise InvalidMessageError(f"Bad message type {msgid[0]} in {msgid}") def __eq__(self, other: Any) -> bool: return ( diff --git a/pylint/pyreverse/inspector.py b/pylint/pyreverse/inspector.py index 042d3845e1..f74dac641f 100644 --- a/pylint/pyreverse/inspector.py +++ b/pylint/pyreverse/inspector.py @@ -101,7 +101,7 @@ def get_children(self) -> list[nodes.Module]: return self.modules def __repr__(self) -> str: - return f"" + return f"" class Linker(IdGeneratorMixIn, utils.LocalsVisitor): diff --git a/tests/checkers/base/unittest_name_preset.py b/tests/checkers/base/unittest_name_preset.py index 49a81deff1..8ea45ecfbc 100644 --- a/tests/checkers/base/unittest_name_preset.py +++ b/tests/checkers/base/unittest_name_preset.py @@ -47,7 +47,7 @@ def _test_is_correct( naming_style: type[base.NamingStyle], name: str, name_type: str ) -> None: rgx = naming_style.get_regex(name_type) - fail = f"{name!r} does not match pattern {rgx!r} (style: {naming_style}, type: {name_type})" + fail = f"{name} does not match pattern {rgx!r} (style: {naming_style}, type: {name_type})" assert rgx.match(name), fail @staticmethod @@ -55,7 +55,7 @@ def _test_is_incorrect( naming_style: type[base.NamingStyle], name: str, name_type: str ) -> None: rgx = naming_style.get_regex(name_type) - fail = f"{name!r} not match pattern {rgx!r} (style: {naming_style}, type: {name_type})" + fail = f"{name} not match pattern {rgx!r} (style: {naming_style}, type: {name_type})" assert not rgx.match(name), fail def test_snake_case(self) -> None: