From 4a4f9378c5eefb8e48743c9cfa113ddbd3efd062 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 23 Oct 2026 08:42:02 +0200 Subject: [PATCH] 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. --- napalm_yealink/yealink.py | 17 +++++++++++------ pyproject.toml | 11 +++++++++++ tests/test_capabilities.py | 4 +++- tests/test_fingerprint.py | 1 + 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/napalm_yealink/yealink.py b/napalm_yealink/yealink.py index 91326cd..ba10874 100644 --- a/napalm_yealink/yealink.py +++ b/napalm_yealink/yealink.py @@ -18,10 +18,9 @@ import socket from typing import Any import requests -from requests.exceptions import RequestException - -from napalm.base.exceptions import ConnectionClosedException, ConnectionException +from napalm.base.exceptions import ConnectionException from napalm_device_types import FingerprintRule, PhoneDriver +from requests.exceptions import RequestException class YealinkDriver(PhoneDriver): @@ -36,7 +35,9 @@ class YealinkDriver(PhoneDriver): "80:5E:0C", # YEALINK(XIAMEN) NETWORK TECHNOLOGY — IEEE, verifiziert an T58V ] 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-w", weight=5.0), FingerprintRule("sip-cp", weight=5.0), @@ -144,7 +145,9 @@ class YealinkDriver(PhoneDriver): def get_interfaces(self) -> dict: 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 def get_interfaces_ip(self) -> dict: @@ -192,7 +195,9 @@ class YealinkDriver(PhoneDriver): def cli(self, commands: list[str], encoding: str = "text") -> dict: 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 def load_merge_candidate(self, filename: str | None = None, config: str | None = None) -> None: diff --git a/pyproject.toml b/pyproject.toml index cd19958..0488635 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,3 +22,14 @@ yealink = "napalm_yealink:YealinkDriver" [tool.setuptools.packages.find] where = ["."] 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"] diff --git a/tests/test_capabilities.py b/tests/test_capabilities.py index e32695d..ad7fd78 100644 --- a/tests/test_capabilities.py +++ b/tests/test_capabilities.py @@ -9,6 +9,8 @@ import pytest 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): assert name not in vars(YealinkDriver) diff --git a/tests/test_fingerprint.py b/tests/test_fingerprint.py index 43e99dd..229fe2f 100644 --- a/tests/test_fingerprint.py +++ b/tests/test_fingerprint.py @@ -1,6 +1,7 @@ """Fingerprint tests for YealinkDriver.""" from napalm_device_types import DeviceTypeDriver, PhoneDriver, role_keys_of + from napalm_yealink import YealinkDriver