From ef7c076b1837cbbab8fc1122eb15b997edca2c43 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Wed, 31 Aug 2022 19:46:12 +0100 Subject: [PATCH 1/2] Handle flake8-bugbear B023, rather than ignore it --- src/poetry/plugins/application_plugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/poetry/plugins/application_plugin.py b/src/poetry/plugins/application_plugin.py index 4dbdb92e5ac..4b2c8f905f4 100644 --- a/src/poetry/plugins/application_plugin.py +++ b/src/poetry/plugins/application_plugin.py @@ -1,5 +1,7 @@ from __future__ import annotations +import functools + from typing import TYPE_CHECKING from poetry.plugins.base_plugin import BasePlugin @@ -22,8 +24,12 @@ def commands(self) -> list[type[Command]]: return [] def activate(self, application: Application) -> None: + def factory(command: type[Command]) -> Command: + return command() + for command in self.commands: assert command.name is not None + application.command_loader.register_factory( - command.name, lambda: command() # noqa: B023 + command.name, functools.partial(factory, command) ) From 10a4e2d9f210a22ff3ec536b5574dce3e6337df5 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Wed, 31 Aug 2022 19:56:08 +0100 Subject: [PATCH 2/2] more compact fix --- src/poetry/plugins/application_plugin.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/poetry/plugins/application_plugin.py b/src/poetry/plugins/application_plugin.py index 4b2c8f905f4..7d9702e694d 100644 --- a/src/poetry/plugins/application_plugin.py +++ b/src/poetry/plugins/application_plugin.py @@ -1,7 +1,5 @@ from __future__ import annotations -import functools - from typing import TYPE_CHECKING from poetry.plugins.base_plugin import BasePlugin @@ -24,12 +22,6 @@ def commands(self) -> list[type[Command]]: return [] def activate(self, application: Application) -> None: - def factory(command: type[Command]) -> Command: - return command() - for command in self.commands: assert command.name is not None - - application.command_loader.register_factory( - command.name, functools.partial(factory, command) - ) + application.command_loader.register_factory(command.name, command)