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:
Christian Manivong committed 2026-10-23 08:42:02 +02:00
1 parent 8d38e6f119
commit 4a4f9378c5
4 files changed
+26 -7

No files matched your search

+11 -6
View File
@@ -18,10 +18,9 @@ import socket
from typing import Any from typing import Any
import requests import requests
from requests.exceptions import RequestException from napalm.base.exceptions import ConnectionException
from napalm.base.exceptions import ConnectionClosedException, ConnectionException
from napalm_device_types import FingerprintRule, PhoneDriver from napalm_device_types import FingerprintRule, PhoneDriver
from requests.exceptions import RequestException
class YealinkDriver(PhoneDriver): class YealinkDriver(PhoneDriver):
@@ -36,7 +35,9 @@ class YealinkDriver(PhoneDriver):
"80:5E:0C", # YEALINK(XIAMEN) NETWORK TECHNOLOGY — IEEE, verifiziert an T58V "80:5E:0C", # YEALINK(XIAMEN) NETWORK TECHNOLOGY — IEEE, verifiziert an T58V
] ]
HTTP_FINGERPRINT = [ HTTP_FINGERPRINT = [
FingerprintRule("yealink", weight=10.0), # nicht mandatory: Yealink/api redirect hat kein "yealink" im Body FingerprintRule(
"yealink", weight=10.0
), # nicht mandatory: Yealink/api redirect hat kein "yealink" im Body
FingerprintRule("sip-t", weight=5.0), FingerprintRule("sip-t", weight=5.0),
FingerprintRule("sip-w", weight=5.0), FingerprintRule("sip-w", weight=5.0),
FingerprintRule("sip-cp", weight=5.0), FingerprintRule("sip-cp", weight=5.0),
@@ -144,7 +145,9 @@ class YealinkDriver(PhoneDriver):
def get_interfaces(self) -> dict: def get_interfaces(self) -> dict:
raise NotImplementedError raise NotImplementedError
def get_config(self, retrieve: str = "all", full: bool = False, sanitized: bool = False) -> dict: def get_config(
self, retrieve: str = "all", full: bool = False, sanitized: bool = False
) -> dict:
raise NotImplementedError raise NotImplementedError
def get_interfaces_ip(self) -> dict: def get_interfaces_ip(self) -> dict:
@@ -192,7 +195,9 @@ class YealinkDriver(PhoneDriver):
def cli(self, commands: list[str], encoding: str = "text") -> dict: def cli(self, commands: list[str], encoding: str = "text") -> dict:
raise NotImplementedError raise NotImplementedError
def load_replace_candidate(self, filename: str | None = None, config: str | None = None) -> None: def load_replace_candidate(
self, filename: str | None = None, config: str | None = None
) -> None:
raise NotImplementedError raise NotImplementedError
def load_merge_candidate(self, filename: str | None = None, config: str | None = None) -> None: def load_merge_candidate(self, filename: str | None = None, config: str | None = None) -> None:
+11
View File
@@ -22,3 +22,14 @@ yealink = "napalm_yealink:YealinkDriver"
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
where = ["."] where = ["."]
include = ["napalm_yealink*"] include = ["napalm_yealink*"]
[tool.ruff]
line-length = 100
target-version = "py310"
[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B"]
[tool.ruff.lint.per-file-ignores]
# Recorded device output keeps its lines.
"tests/**" = ["E501"]
+3 -1
View File
@@ -9,6 +9,8 @@ import pytest
from napalm_yealink.yealink import YealinkDriver from napalm_yealink.yealink import YealinkDriver
@pytest.mark.parametrize("name", ["get_health_metrics", "get_ssids", "get_radio_info", "get_wireless_clients"]) @pytest.mark.parametrize(
"name", ["get_health_metrics", "get_ssids", "get_radio_info", "get_wireless_clients"]
)
def test_no_stub_claims_what_the_phone_cannot_do(name): def test_no_stub_claims_what_the_phone_cannot_do(name):
assert name not in vars(YealinkDriver) assert name not in vars(YealinkDriver)
+1
View File
@@ -1,6 +1,7 @@
"""Fingerprint tests for YealinkDriver.""" """Fingerprint tests for YealinkDriver."""
from napalm_device_types import DeviceTypeDriver, PhoneDriver, role_keys_of from napalm_device_types import DeviceTypeDriver, PhoneDriver, role_keys_of
from napalm_yealink import YealinkDriver from napalm_yealink import YealinkDriver