style: ruff format and the lint rules of the driver standard
Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM driver uses (E, F, I, UP, B at line length 100, Python 3.10). What ruff cannot fix comes in the next commit.
This commit is contained in:
1 parent
692a584fd2
commit
571d9abb5f
15 files changed
+690
-419
No files matched your search
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -45,8 +44,9 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import time
|
||||
from collections.abc import Callable, Iterable
|
||||
from ipaddress import ip_address
|
||||
from typing import Any, Callable, Iterable, Optional
|
||||
from typing import Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -78,7 +78,7 @@ class OPNsensePingMixin:
|
||||
PING_SWEEP_MAX_TARGETS: int = 512
|
||||
|
||||
# Provided by the driver this mixin is mixed into.
|
||||
_ping_model_path_cache: Optional[tuple[str, ...]] = None
|
||||
_ping_model_path_cache: tuple[str, ...] | None = None
|
||||
|
||||
# ── NAPALM ───────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -119,9 +119,9 @@ class OPNsensePingMixin:
|
||||
*,
|
||||
count: int = 1,
|
||||
timeout: int = 1,
|
||||
max_targets: Optional[int] = None,
|
||||
on_progress: Optional[Callable[[int, int], None]] = None,
|
||||
should_stop: Optional[Callable[[], bool]] = None,
|
||||
max_targets: int | None = None,
|
||||
on_progress: Callable[[int, int], None] | None = None,
|
||||
should_stop: Callable[[], bool] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Ping many destinations, one batch of parallel firewall jobs at a time.
|
||||
|
||||
@@ -245,9 +245,7 @@ class OPNsensePingMixin:
|
||||
if attempt:
|
||||
time.sleep(_POLL_INTERVAL)
|
||||
rows = {
|
||||
job_id: row
|
||||
for job_id, row in self._read_ping_jobs().items()
|
||||
if job_id in wanted
|
||||
job_id: row for job_id, row in self._read_ping_jobs().items() if job_id in wanted
|
||||
}
|
||||
if wanted and all(
|
||||
_as_int(rows.get(job_id, {}).get("send")) >= count for job_id in wanted
|
||||
@@ -325,7 +323,7 @@ class OPNsensePingMixin:
|
||||
|
||||
@staticmethod
|
||||
def _row_to_napalm_reply(
|
||||
destination: str, row: Optional[dict[str, Any]], *, count: int
|
||||
destination: str, row: dict[str, Any] | None, *, count: int
|
||||
) -> dict[str, Any]:
|
||||
"""Turn one ``search_jobs`` row into NAPALM's ping reply shape.
|
||||
|
||||
|
||||
Reference in new issue
Block a user