Skip to content

Commit f9b2ea2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a650846 commit f9b2ea2

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

anta/device.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
import httpcore
1616
from aiocache import Cache
1717
from aiocache.plugins import HitMissRatioPlugin
18-
from asynceapi import Device, EapiCommandError
1918
from asyncssh import SSHClientConnection, SSHClientConnectionOptions
2019
from httpx import ConnectError, HTTPError, Limits, TimeoutException
2120

2221
from anta import __DEBUG__
2322
from anta.logger import anta_log_exception, exc_to_str
2423
from anta.models import AntaCommand
24+
from asynceapi import Device, EapiCommandError
2525

2626
if TYPE_CHECKING:
2727
from collections.abc import Iterator
@@ -332,7 +332,7 @@ async def _handle_eapi_command_error(self, exception: EapiCommandError, anta_com
332332
logger.error("Command '%s' is not supported on %s (%s).", anta_command.command, self.name, self.hw_model)
333333

334334
# 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)
336336

337337
def _handle_timeout_exception(self, exception: TimeoutException, anta_commands: list[AntaCommand]) -> None:
338338
"""Handle TimeoutException exceptions."""
@@ -357,7 +357,9 @@ def _handle_connect_os_error(self, exception: ConnectError | OSError, anta_comma
357357
for anta_command in anta_commands:
358358
anta_command.errors = [exc_to_str(exception)]
359359

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+
):
361363
if isinstance(os_error.__cause__, OSError):
362364
os_error = os_error.__cause__
363365
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
385387
collection_id: An identifier used to build the eAPI request ID.
386388
"""
387389
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}
390391
for anta_command in anta_commands
391392
]
392393

anta/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def render(self, **params: str | int | bool) -> AntaCommand:
127127
use_cache=self.use_cache,
128128
)
129129

130+
130131
class CommandWeight(Enum):
131132
"""Enum to define the weight of a command.
132133
@@ -138,6 +139,7 @@ class CommandWeight(Enum):
138139
MEDIUM = "medium"
139140
HEAVY = "heavy"
140141

142+
141143
class AntaCommand(BaseModel):
142144
"""Class to define a command.
143145
@@ -660,6 +662,7 @@ def test(self) -> None:
660662
661663
"""
662664

665+
663666
class AntaTestManager:
664667
"""TODO: Add docstring.
665668

anta/runner.py

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def prepare_tests(
155155

156156
return device_to_tests
157157

158+
158159
async def run_device_tests(device: AntaDevice, test_definitions: set[AntaTestDefinition], batch_size: int) -> list[TestResult]:
159160
"""Run tests for a specific device using the AntaTestManager."""
160161
manager = AntaTestManager(device=device, batch_size=batch_size)

0 commit comments

Comments
 (0)