Commit 7ab4cf3a by Arun Babu Neelicattu

application: make installer configuration public

parent 7ed1da26
...@@ -109,7 +109,7 @@ class Application(BaseApplication): # type: ignore[misc] ...@@ -109,7 +109,7 @@ class Application(BaseApplication): # type: ignore[misc]
dispatcher = EventDispatcher() dispatcher = EventDispatcher()
dispatcher.add_listener(COMMAND, self.register_command_loggers) dispatcher.add_listener(COMMAND, self.register_command_loggers)
dispatcher.add_listener(COMMAND, self.configure_env) dispatcher.add_listener(COMMAND, self.configure_env)
dispatcher.add_listener(COMMAND, self.configure_installer) dispatcher.add_listener(COMMAND, self.configure_installer_for_event)
self.set_event_dispatcher(dispatcher) self.set_event_dispatcher(dispatcher)
command_loader = CommandLoader({name: load_command(name) for name in COMMANDS}) command_loader = CommandLoader({name: load_command(name) for name in COMMANDS})
...@@ -301,8 +301,9 @@ class Application(BaseApplication): # type: ignore[misc] ...@@ -301,8 +301,9 @@ class Application(BaseApplication): # type: ignore[misc]
command.set_env(env) command.set_env(env)
def configure_installer( @classmethod
self, event: ConsoleCommandEvent, event_name: str, _: Any def configure_installer_for_event(
cls, event: ConsoleCommandEvent, event_name: str, _: Any
) -> None: ) -> None:
from poetry.console.commands.installer_command import InstallerCommand from poetry.console.commands.installer_command import InstallerCommand
...@@ -315,9 +316,10 @@ class Application(BaseApplication): # type: ignore[misc] ...@@ -315,9 +316,10 @@ class Application(BaseApplication): # type: ignore[misc]
if command.installer is not None: if command.installer is not None:
return return
self._configure_installer(command, event.io) cls.configure_installer_for_command(command, event.io)
def _configure_installer(self, command: InstallerCommand, io: IO) -> None: @staticmethod
def configure_installer_for_command(command: InstallerCommand, io: IO) -> None:
from poetry.installation.installer import Installer from poetry.installation.installer import Installer
poetry = command.poetry poetry = command.poetry
......
...@@ -49,7 +49,7 @@ It works similarly to the <c1>add</c1> command: ...@@ -49,7 +49,7 @@ It works similarly to the <c1>add</c1> command:
application = cast(Application, self.application) application = cast(Application, self.application)
command: SelfAddCommand = cast(SelfAddCommand, application.find("self add")) command: SelfAddCommand = cast(SelfAddCommand, application.find("self add"))
application._configure_installer(command, self.io) application.configure_installer_for_command(command, self.io)
argv: list[str] = ["add", *self.argument("plugins")] argv: list[str] = ["add", *self.argument("plugins")]
......
...@@ -43,7 +43,7 @@ class PluginRemoveCommand(Command): ...@@ -43,7 +43,7 @@ class PluginRemoveCommand(Command):
command: SelfRemoveCommand = cast( command: SelfRemoveCommand = cast(
SelfRemoveCommand, application.find("self remove") SelfRemoveCommand, application.find("self remove")
) )
application._configure_installer(command, self.io) application.configure_installer_for_command(command, self.io)
argv: list[str] = ["remove", *self.argument("plugins")] argv: list[str] = ["remove", *self.argument("plugins")]
......
...@@ -40,7 +40,7 @@ environment. ...@@ -40,7 +40,7 @@ environment.
application = cast(Application, self.application) application = cast(Application, self.application)
add_command: AddCommand = cast(AddCommand, application.find("add")) add_command: AddCommand = cast(AddCommand, application.find("add"))
add_command.set_env(self.env) add_command.set_env(self.env)
application._configure_installer(add_command, self._io) application.configure_installer_for_command(add_command, self._io)
argv = ["add", f"poetry@{self.argument('version')}"] argv = ["add", f"poetry@{self.argument('version')}"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment