diff --git a/napalm_device_types/__init__.py b/napalm_device_types/__init__.py index 6308372..573b4ba 100644 --- a/napalm_device_types/__init__.py +++ b/napalm_device_types/__init__.py @@ -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, diff --git a/napalm_device_types/firmware.py b/napalm_device_types/firmware.py index d1d892b..9540355 100644 --- a/napalm_device_types/firmware.py +++ b/napalm_device_types/firmware.py @@ -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, diff --git a/napalm_device_types/models.py b/napalm_device_types/models.py index 69fd04a..66667ba 100644 --- a/napalm_device_types/models.py +++ b/napalm_device_types/models.py @@ -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 diff --git a/tests/quality_baseline.json b/tests/quality_baseline.json index 06714cf..73db258 100644 --- a/tests/quality_baseline.json +++ b/tests/quality_baseline.json @@ -31,7 +31,7 @@ }, "mypy_relaxed": [], "python_file_lines": { - "napalm_device_types/models.py": 1442 + "napalm_device_types/models.py": 1436 }, "untyped_public": [] }