15
15
import httpcore
16
16
from aiocache import Cache
17
17
from aiocache .plugins import HitMissRatioPlugin
18
- from asynceapi import Device , EapiCommandError
19
18
from asyncssh import SSHClientConnection , SSHClientConnectionOptions
20
19
from httpx import ConnectError , HTTPError , Limits , TimeoutException
21
20
22
21
from anta import __DEBUG__
23
22
from anta .logger import anta_log_exception , exc_to_str
24
23
from anta .models import AntaCommand
24
+ from asynceapi import Device , EapiCommandError
25
25
26
26
if TYPE_CHECKING :
27
27
from collections .abc import Iterator
@@ -332,7 +332,7 @@ async def _handle_eapi_command_error(self, exception: EapiCommandError, anta_com
332
332
logger .error ("Command '%s' is not supported on %s (%s)." , anta_command .command , self .name , self .hw_model )
333
333
334
334
# Collect the commands that were not executed
335
- await self ._collect (anta_commands = anta_commands [err_at + 1 :], req_format = req_format , req_id = req_id )
335
+ await self ._collect (anta_commands = anta_commands [err_at + 1 :], req_format = req_format , req_id = req_id )
336
336
337
337
def _handle_timeout_exception (self , exception : TimeoutException , anta_commands : list [AntaCommand ]) -> None :
338
338
"""Handle TimeoutException exceptions."""
@@ -357,7 +357,9 @@ def _handle_connect_os_error(self, exception: ConnectError | OSError, anta_comma
357
357
for anta_command in anta_commands :
358
358
anta_command .errors = [exc_to_str (exception )]
359
359
360
- if (isinstance (exc := exception .__cause__ , httpcore .ConnectError ) and isinstance (os_error := exc .__context__ , OSError )) or isinstance (os_error := exception , OSError ):
360
+ if (isinstance (exc := exception .__cause__ , httpcore .ConnectError ) and isinstance (os_error := exc .__context__ , OSError )) or isinstance (
361
+ os_error := exception , OSError
362
+ ):
361
363
if isinstance (os_error .__cause__ , OSError ):
362
364
os_error = os_error .__cause__
363
365
logger .error ("A local OS error occurred while connecting to %s: %s." , self .name , os_error )
@@ -385,8 +387,7 @@ async def _collect(self, anta_commands: list[AntaCommand], *, req_format: Litera
385
387
collection_id: An identifier used to build the eAPI request ID.
386
388
"""
387
389
commands = [
388
- {"cmd" : anta_command .command , "revision" : anta_command .revision }
389
- if anta_command .revision else {"cmd" : anta_command .command }
390
+ {"cmd" : anta_command .command , "revision" : anta_command .revision } if anta_command .revision else {"cmd" : anta_command .command }
390
391
for anta_command in anta_commands
391
392
]
392
393
0 commit comments