From ad69c0e643c0d20e6b42a5d7aee5b4dc8ef28f2e Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 23 Oct 2026 08:55:35 +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_sonos/sonos_driver.py | 6 +----- pyproject.toml | 9 ++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/napalm_sonos/sonos_driver.py b/napalm_sonos/sonos_driver.py index d848fde..160e09f 100644 --- a/napalm_sonos/sonos_driver.py +++ b/napalm_sonos/sonos_driver.py @@ -4,7 +4,6 @@ import socket from typing import Any from napalm.base.exceptions import ConnectionException - from napalm_device_types import FingerprintRule, MediaDriver, PortSpec """NAPALM driver for Sonos speakers. @@ -15,7 +14,6 @@ media-playback controls. """ - class SonosDriver(MediaDriver): """NAPALM driver for controlling Sonos speakers. @@ -74,9 +72,7 @@ class SonosDriver(MediaDriver): if self._device is None: return {"is_alive": False} try: - sock = socket.create_connection( - (self.hostname, 1400), timeout=5 - ) + sock = socket.create_connection((self.hostname, 1400), timeout=5) sock.close() return {"is_alive": True} except OSError: diff --git a/pyproject.toml b/pyproject.toml index 57dbe61..78098de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,14 @@ include = ["napalm_sonos*"] [tool.ruff] line-length = 100 -target-version = "py39" +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"] [tool.pytest.ini_options] testpaths = ["tests"]