refactor(firmware): FirmwareOfferDict lives with its contract
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 16s
driver / types (pull_request) Successful in 50s
driver / test (3.13) (pull_request) Successful in 59s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / lowest (pull_request) Successful in 35s
driver / build (pull_request) Successful in 24s
driver / security (pull_request) Successful in 53s
CI / driver (pull_request) Successful in 2m9s
driver / publish (pull_request) Skipped

models.py is over the file limit and may not grow; the offer's two new
fields moved it past its recorded length. It is still importable from
napalm_device_types.models.
This commit is contained in:
christianmanivong committed 2026-11-17 12:35:34 +01:00
1 parent 71588613fb
commit 1a7885d22e
4 files changed
+23 -24

No files matched your search

+1 -2
View File
@@ -138,7 +138,7 @@ from napalm_device_types.dhcp import DhcpApplyError, DhcpServerMixin, normalize_
from napalm_device_types.dns_forward import DnsForwardMixin
from napalm_device_types.firewall import FirewallDriver
from napalm_device_types.firewall_rules import FirewallRuleMixin
from napalm_device_types.firmware import FirmwareOfferMixin, FirmwareUpgradeMixin
from napalm_device_types.firmware import FirmwareOfferDict, FirmwareOfferMixin, FirmwareUpgradeMixin
from napalm_device_types.fixes import (
EnsurePackageMixin,
LldpAgentMixin,
@@ -205,7 +205,6 @@ from napalm_device_types.models import (
DnsForwardDict,
EventLogEntryDict,
FirmwareDict,
FirmwareOfferDict,
FixResultDict,
FixStepDict,
FixStepOutcomeDict,
+17 -4
View File
@@ -10,17 +10,30 @@ Installing it is a capability of its own (``FirmwareUpgradeMixin``): when and
whether is the caller's call, as with package updates; how is the driver's.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, NotRequired, TypedDict
from typing import TYPE_CHECKING
from napalm_device_types.models import FirmwareOfferDict
class FirmwareOfferDict(TypedDict):
"""The firmware a device runs and the newest its vendor offers
(``FirmwareOfferMixin.get_firmware_offer``). A fact, not a judgement."""
current_version: str
latest_version: str
newer: bool # the offer is newer than what runs, by the vendor's versioning
download_url: NotRequired[str]
# The driver can install latest_version itself (FirmwareUpgradeMixin) now; False
# while the device lacks what that takes (OpenWrt without owut). Left out where
# the driver never installs firmware on this device.
installable: NotRequired[bool]
# The newest of a later release line (OpenWrt 25.12 on a 24.10 device), which
# latest_version does not cross to: shown, never installed by the driver.
latest_major_version: NotRequired[str]
class FirmwareOfferMixin:
if TYPE_CHECKING: # pragma: no cover - declared for type checkers only
def get_firmware_offer(self) -> FirmwareOfferDict | None:
def get_firmware_offer(self) -> "FirmwareOfferDict | None":
"""The firmware running and the newest the vendor offers.
None when the driver cannot tell for this device (an unknown model,
+4 -17
View File
@@ -1172,23 +1172,6 @@ class OspfDict(TypedDict):
interfaces: dict[str, OspfInterfaceDict] # by interface name
class FirmwareOfferDict(TypedDict):
"""The firmware a device runs and the newest its vendor offers
(``FirmwareOfferMixin.get_firmware_offer``). A fact, not a judgement."""
current_version: str
latest_version: str
newer: bool # the offer is newer than what runs, by the vendor's versioning
download_url: NotRequired[str]
# The driver can install latest_version itself (FirmwareUpgradeMixin) now; False
# while the device lacks what that takes (OpenWrt without owut). Left out where
# the driver never installs firmware on this device.
installable: NotRequired[bool]
# The newest of a later release line (OpenWrt 25.12 on a 24.10 device), which
# latest_version does not cross to: shown, never installed by the driver.
latest_major_version: NotRequired[str]
class HypervisorHostDict(TypedDict):
"""One host of a hypervisor or cluster (``HypervisorDriver.get_hypervisor_hosts``)."""
@@ -1447,3 +1430,7 @@ class ManagementProtocolsDict(TypedDict):
snmp: ProtocolStateDict
kvm: ProtocolStateDict
virtual_media: ProtocolStateDict
# Importable from here as before 4.41; it lives with its contract now.
from napalm_device_types.firmware import FirmwareOfferDict as FirmwareOfferDict # noqa: E402
+1 -1
View File
@@ -31,7 +31,7 @@
},
"mypy_relaxed": [],
"python_file_lines": {
"napalm_device_types/models.py": 1442
"napalm_device_types/models.py": 1436
},
"untyped_public": []
}