diff --git a/CHANGES.rst b/CHANGES.rst index abd215b26..8afb72189 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -41,6 +41,7 @@ fixes: - chore: update repos.json (#1660) - docs: add readthedocs yaml config (#1661) - fix: broken integration tests (#1668) +- style: replace format() with f-strings (#1667) v6.1.9 (2022-06-11) diff --git a/docs/user_guide/plugin_development/webhooks.rst b/docs/user_guide/plugin_development/webhooks.rst index 34b47cd06..3777d83b2 100644 --- a/docs/user_guide/plugin_development/webhooks.rst +++ b/docs/user_guide/plugin_development/webhooks.rst @@ -115,7 +115,7 @@ which contains all the details about the actual request: @webhook(raw=True) def test(self, request): user_agent = request.headers.get("user-agent", "Unknown") - return "Your user-agent is {}".format(user_agent) + return f"Your user-agent is {user_agent}" Returning custom headers and status codes diff --git a/errbot/botplugin.py b/errbot/botplugin.py index dcdeffc79..79b50b009 100644 --- a/errbot/botplugin.py +++ b/errbot/botplugin.py @@ -134,9 +134,7 @@ def append_args(self, args, kwargs): update_wrapper(self.definition, args, kwargs) else: log.warning( - "Attempting to append arguments to {} isn't supported.".format( - self.definition - ) + f"Attempting to append arguments to {self.definition} isn't supported." ) diff --git a/errbot/core_plugins/vcheck.py b/errbot/core_plugins/vcheck.py index 2a536111f..ef0f2c0a0 100644 --- a/errbot/core_plugins/vcheck.py +++ b/errbot/core_plugins/vcheck.py @@ -47,9 +47,7 @@ def _get_version(self): # noinspection PyBroadException try: possible_versions = requests.get(HOME).json() - version = possible_versions.get( - "python{}".format(major_py_version), VERSION - ) + version = possible_versions.get(f"python{major_py_version}", VERSION) self.log.debug("Latest Errbot version is: %s", version) except (HTTPError, URLError, ConnectionError, JSONDecodeError): self.log.info("Could not establish connection to retrieve latest version.") diff --git a/tests/base_backend_test.py b/tests/base_backend_test.py index dadc6114b..5406356dc 100644 --- a/tests/base_backend_test.py +++ b/tests/base_backend_test.py @@ -1003,9 +1003,9 @@ def test_access_controls(dummy_backend): dummy_backend.bot_config.ACCESS_CONTROLS = test.get("acl", {}) dummy_backend.bot_config.BOT_ADMINS = test.get("bot_admins", ()) logger = logging.getLogger(__name__) - logger.info("** message: {}".format(test["message"].body)) - logger.info("** bot_admins: {}".format(dummy_backend.bot_config.BOT_ADMINS)) - logger.info("** acl: {!r}".format(dummy_backend.bot_config.ACCESS_CONTROLS)) + logger.info(f"** message: {test['message'].body}") + logger.info(f"** bot_admins: {dummy_backend.bot_config.BOT_ADMINS}") + logger.info(f"** acl: {dummy_backend.bot_config.ACCESS_CONTROLS}") logger.info( "** acl_default: {!r}".format( dummy_backend.bot_config.ACCESS_CONTROLS_DEFAULT diff --git a/tests/commandnotfound_plugin/commandnotfound.py b/tests/commandnotfound_plugin/commandnotfound.py index 3fe7e1158..4a2485794 100644 --- a/tests/commandnotfound_plugin/commandnotfound.py +++ b/tests/commandnotfound_plugin/commandnotfound.py @@ -7,4 +7,4 @@ def command_not_found(self, msg, cmd, args, dry_run, emptycmd=False): if not emptycmd: return msg, cmd, args - return "Command fell through: {}".format(msg) + return f"Command fell through: {msg}" diff --git a/tests/commands_test.py b/tests/commands_test.py index 397596e31..8d33df577 100644 --- a/tests/commands_test.py +++ b/tests/commands_test.py @@ -112,9 +112,7 @@ def test_plugin_cycle(testbot): ] for plugin in plugins: - testbot.assertInCommand( - "!repos install {0}".format(plugin), "Installing {0}...".format(plugin) - ), + testbot.assertInCommand(f"!repos install {plugin}", f"Installing {plugin}..."), assert ( "A new plugin repository has been installed correctly from errbotio/err-helloworld" in testbot.pop_message(timeout=60) @@ -231,7 +229,7 @@ def test_webserver_webhook_test(testbot): def test_activate_reload_and_deactivate(testbot): for command in ("activate", "reload", "deactivate"): - testbot.push_message("!plugin {}".format(command)) + testbot.push_message(f"!plugin {command}") m = testbot.pop_message() assert "Please tell me which of the following plugins to" in m assert "ChatRoom" in m @@ -350,7 +348,7 @@ def test_callback_no_command(testbot): ) cmd = "!this_is_not_a_real_command_at_all" - expected_str = "Command fell through: {}".format(cmd) + expected_str = f"Command fell through: {cmd}" testbot.exec_command("!plugin deactivate CommandNotFoundFilter") testbot.bot.plugin_manager._extra_plugin_dir = extra_plugin_dir diff --git a/tests/room_plugin/roomtest.py b/tests/room_plugin/roomtest.py index 4571624df..fbf87b482 100644 --- a/tests/room_plugin/roomtest.py +++ b/tests/room_plugin/roomtest.py @@ -13,13 +13,13 @@ def activate(self): def callback_room_joined(self, room, user, invited_by): log.info("join") - self.events.put("callback_room_joined {!s}".format(room)) + self.events.put(f"callback_room_joined {room}") def callback_room_left(self, room, user, kicked_by): - self.events.put("callback_room_left {!s}".format(room)) + self.events.put(f"callback_room_left {room}") def callback_room_topic(self, room): - self.events.put("callback_room_topic {}".format(room.topic)) + self.events.put(f"callback_room_topic {room.topic}") def purge(self): log.info("purge")