From 23bc5f206a0daeffce8b00fe8093494528595563 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 13 Nov 2026 21:45:24 +0100 Subject: [PATCH] fix(driver): load_replace_candidate is None, not a stub that raises (NetOrk/netork#2503) The driver cannot replace a device's configuration, and said so with a load_replace_candidate that raised NotImplementedError. A method that only raises still looks like a replace to anyone who asks whether the driver has one: netOrk offered a config restore for these devices that could only fail. None is how a driver switches off a method, the convention netOrk's capability checks and napalm-device-types follow, so asking now says no. Nothing in the driver calls it. --- CHANGELOG.md | 4 ++++ napalm_yealink/yealink.py | 7 +++---- tests/test_config_replace.py | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 tests/test_config_replace.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a96775..0810935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ All notable changes to this driver. The format follows ## [Unreleased] ### Changed +- `load_replace_candidate` is `None` instead of a method that raises + `NotImplementedError`, so a caller that asks whether the driver can replace a + configuration gets no. netOrk offered a config restore for these devices that + could only fail (NetOrk/netork#2503). - Python 3.12 is the floor (`requires-python = ">=3.12"`): netOrk runs every driver on 3.12, so 3.10 and 3.11 are no longer tested (NAPALM/driver-standard#6). - The floor on napalm is 5.1: older releases import `pkg_resources`, which a Python diff --git a/napalm_yealink/yealink.py b/napalm_yealink/yealink.py index 6bc22e1..6c220ed 100644 --- a/napalm_yealink/yealink.py +++ b/napalm_yealink/yealink.py @@ -199,10 +199,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: - raise NotImplementedError + #: No config replace: switched off rather than a stub that raises, so asking + #: whether the driver has one says no (NetOrk/netork#2503). + load_replace_candidate = None # type: ignore[assignment] def load_merge_candidate(self, filename: str | None = None, config: str | None = None) -> None: raise NotImplementedError diff --git a/tests/test_config_replace.py b/tests/test_config_replace.py new file mode 100644 index 0000000..1cd3c08 --- /dev/null +++ b/tests/test_config_replace.py @@ -0,0 +1,17 @@ +"""The driver cannot replace a device's configuration, and says so by not having the method. + +A ``load_replace_candidate`` that only raises looks like a replace to anyone who asks +whether the driver has one: netOrk offered a config restore for these devices that +could only fail (NetOrk/netork#2503). ``None`` is how a driver switches off a method +it would otherwise inherit, the convention of napalm-device-types and netOrk's +capability checks. +""" + +from __future__ import annotations + +from napalm_yealink import YealinkDriver + + +def test_the_driver_has_no_config_replace(): + assert YealinkDriver.load_replace_candidate is None + assert not callable(getattr(YealinkDriver, "load_replace_candidate", None)) -- 2.54.1