6
6
from contextlib import suppress
7
7
from importlib import import_module
8
8
from typing import TYPE_CHECKING
9
- from typing import Any
10
9
from typing import cast
11
10
12
11
from cleo .application import Application as BaseApplication
12
+ from cleo .events .console_command_event import ConsoleCommandEvent
13
13
from cleo .events .console_events import COMMAND
14
14
from cleo .events .event_dispatcher import EventDispatcher
15
- from cleo .exceptions import CleoException
15
+ from cleo .exceptions import CleoError
16
16
from cleo .formatters .style import Style
17
17
from cleo .io .null_io import NullIO
18
18
24
24
if TYPE_CHECKING :
25
25
from collections .abc import Callable
26
26
27
- from cleo .events .console_command_event import ConsoleCommandEvent
27
+ from cleo .events .event import Event
28
28
from cleo .io .inputs .argv_input import ArgvInput
29
29
from cleo .io .inputs .definition import Definition
30
30
from cleo .io .inputs .input import Input
@@ -93,7 +93,7 @@ def _load() -> Command:
93
93
]
94
94
95
95
96
- class Application (BaseApplication ): # type: ignore[misc]
96
+ class Application (BaseApplication ):
97
97
def __init__ (self ) -> None :
98
98
super ().__init__ ("poetry" , __version__ )
99
99
@@ -137,8 +137,8 @@ def poetry(self) -> Poetry:
137
137
138
138
@property
139
139
def command_loader (self ) -> CommandLoader :
140
- command_loader : CommandLoader | None = self ._command_loader
141
- assert command_loader is not None
140
+ command_loader = self ._command_loader
141
+ assert isinstance ( command_loader , CommandLoader )
142
142
return command_loader
143
143
144
144
def reset_poetry (self ) -> None :
@@ -194,7 +194,7 @@ def _configure_io(self, io: IO) -> None:
194
194
# We need to check if the command being run
195
195
# is the "run" command.
196
196
definition = self .definition
197
- with suppress (CleoException ):
197
+ with suppress (CleoError ):
198
198
io .input .bind (definition )
199
199
200
200
name = io .input .first_argument
@@ -215,7 +215,7 @@ def _configure_io(self, io: IO) -> None:
215
215
for shortcut in shortcuts :
216
216
run_input .add_parameter_option ("-" + shortcut .lstrip ("-" ))
217
217
218
- with suppress (CleoException ):
218
+ with suppress (CleoError ):
219
219
run_input .bind (definition )
220
220
221
221
for option_name , value in input .options .items ():
@@ -227,12 +227,13 @@ def _configure_io(self, io: IO) -> None:
227
227
super ()._configure_io (io )
228
228
229
229
def register_command_loggers (
230
- self , event : ConsoleCommandEvent , event_name : str , _ : Any
230
+ self , event : Event , event_name : str , _ : EventDispatcher
231
231
) -> None :
232
232
from poetry .console .logging .filters import POETRY_FILTER
233
233
from poetry .console .logging .io_formatter import IOFormatter
234
234
from poetry .console .logging .io_handler import IOHandler
235
235
236
+ assert isinstance (event , ConsoleCommandEvent )
236
237
command = event .command
237
238
if not isinstance (command , Command ):
238
239
return
@@ -277,12 +278,11 @@ def register_command_loggers(
277
278
278
279
logger .setLevel (_level )
279
280
280
- def configure_env (
281
- self , event : ConsoleCommandEvent , event_name : str , _ : Any
282
- ) -> None :
281
+ def configure_env (self , event : Event , event_name : str , _ : EventDispatcher ) -> None :
283
282
from poetry .console .commands .env_command import EnvCommand
284
283
from poetry .console .commands .self .self_command import SelfCommand
285
284
285
+ assert isinstance (event , ConsoleCommandEvent )
286
286
command = event .command
287
287
if not isinstance (command , EnvCommand ) or isinstance (command , SelfCommand ):
288
288
return
@@ -305,10 +305,11 @@ def configure_env(
305
305
306
306
@classmethod
307
307
def configure_installer_for_event (
308
- cls , event : ConsoleCommandEvent , event_name : str , _ : Any
308
+ cls , event : Event , event_name : str , _ : EventDispatcher
309
309
) -> None :
310
310
from poetry .console .commands .installer_command import InstallerCommand
311
311
312
+ assert isinstance (event , ConsoleCommandEvent )
312
313
command = event .command
313
314
if not isinstance (command , InstallerCommand ):
314
315
return
0 commit comments