feat: a package's architecture, 4.59.0 (NetOrk/netork#2907)
driver / standard (pull_request) Successful in 57s
driver / lint (pull_request) Successful in 1m35s
driver / types (pull_request) Successful in 3m20s
driver / lowest (pull_request) Successful in 1m46s
driver / test (3.13) (pull_request) Successful in 2m42s
driver / test (3.12) (pull_request) Successful in 3m47s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Successful in 4m27s
driver / publish (pull_request) Skipped

PackageDict gains an optional architecture, in the package manager's own
words (x64/x86/arm64 on Windows, amd64/i386 from dpkg, x86_64/noarch
from rpm), so two packages of one name are told apart. A driver that
cannot tell leaves it out. PackageDict moves to package_models, since
models is at its recorded size; models re-exports it.
This commit is contained in:
christianmanivong committed 2026-12-05 01:16:33 +01:00
1 parent e5eb8de316
commit 9d24ac5678
6 files changed
+72 -16

No files matched your search

+12 -1
View File
@@ -7,6 +7,16 @@ recorded here; their history is the git log.
## [Unreleased]
## [4.59.0] - 2026-12-05
### Added
- `PackageDict`: optional `architecture`, the build's architecture in the package
manager's own words (`x64`, `x86`, `arm64` on Windows; `amd64`, `i386`, `all` from
dpkg; `x86_64`, `noarch` from rpm). It tells apart two packages of one name, such as a
multiarch host's `libc6` for amd64 and for i386 (NetOrk/netork#2907). A driver that
cannot tell leaves it out. `PackageDict` moves to `package_models`; `models`
re-exports it, so every import keeps working.
### Fixed
- A key declared `NotRequired` is optional at runtime too: `__optional_keys__` of
`KernelFactsDict`, `HostRepairResultDict`, `LldpNeighborDict`, `LogSourceDict`,
@@ -14,7 +24,8 @@ recorded here; their history is the git log.
and `ZabbixAgentSettingsDict` was empty, and their optional keys read as required. Their
modules postponed annotations (`from __future__ import annotations`), and TypedDict
sees `NotRequired` only in an evaluated annotation. Type checking was not affected. A
test now walks every TypedDict in the package for an annotation it could not read.
test now walks every TypedDict in the package for an annotation it could not read
(#144).
## [4.58.1] - 2026-12-03
+3 -13
View File
@@ -10,8 +10,8 @@ from typing_extensions import TypedDict
# The SNMP health profile shapes live in snmp_health_profile.py, those of the access
# point getters in access_point_models.py, an OS's accounts and processes in
# os_models.py, the host firewall's in host_firewall_models.py; re-exported here,
# where they were.
# os_models.py, the host firewall's in host_firewall_models.py, an installed package's
# in package_models.py; re-exported here, where they were.
from napalm_device_types.access_point_models import ChannelScanEntryDict as ChannelScanEntryDict
from napalm_device_types.access_point_models import (
FastTransitionConfigDict as FastTransitionConfigDict,
@@ -30,6 +30,7 @@ from napalm_device_types.host_firewall_models import NetfilterRuleDict as Netfil
from napalm_device_types.kernel_models import KernelFactsDict as KernelFactsDict
from napalm_device_types.os_models import ProcessDict as ProcessDict
from napalm_device_types.os_models import UserDict as UserDict
from napalm_device_types.package_models import PackageDict as PackageDict
from napalm_device_types.share_models import NASShareDict as NASShareDict
from napalm_device_types.share_models import ShareAccessDict as ShareAccessDict
from napalm_device_types.snmp_health_profile import SnmpHealthProfile as SnmpHealthProfile
@@ -67,17 +68,6 @@ class MACACLDict(TypedDict):
entries: list[MACACLEntryDict]
class PackageDict(TypedDict):
"""A software package / plugin installed on the device."""
name: str
version: str
installed: bool
description: str
size: int
source: str
#: A service's last run ended as it should, or it has not ended (systemd's ``Result``).
SERVICE_RESULT_SUCCESS = "success"
#: A service's last run ended with an exit code that is not success.
+31
View File
@@ -0,0 +1,31 @@
"""The shape of an installed package (``PackageManagementMixin.get_packages``).
A module of its own rather than in :mod:`napalm_device_types.models`, which re-exports
it: the package grew its architecture (NetOrk/netork#2907), and ``models`` is at its
recorded size.
"""
# No ``from __future__ import annotations``: TypedDict tells a ``NotRequired`` key only
# from an evaluated annotation (``PackageDict.__optional_keys__``).
from typing import NotRequired
from typing_extensions import TypedDict
class PackageDict(TypedDict):
"""A software package / plugin installed on the device.
``architecture`` is the build's architecture in the package manager's own words:
``x64``, ``x86`` or ``arm64`` on Windows, ``amd64``, ``i386`` or ``all`` from dpkg,
``x86_64`` or ``noarch`` from rpm. It tells apart two packages of one name, as a
Debian multiarch host's ``libc6`` for amd64 and for i386 or a 32-bit and a 64-bit
install of one Windows program. A driver that cannot tell leaves it out.
"""
name: str
version: str
installed: bool
description: str
size: int
source: str
architecture: NotRequired[str]
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "napalm-device-types"
version = "4.58.1"
version = "4.59.0"
description = "Abstract device-type base classes for NAPALM drivers"
readme = "README.md"
requires-python = ">=3.12"
+1 -1
View File
@@ -31,7 +31,7 @@
},
"mypy_relaxed": [],
"python_file_lines": {
"napalm_device_types/models.py": 1286
"napalm_device_types/models.py": 1276
},
"untyped_public": []
}
+24
View File
@@ -0,0 +1,24 @@
"""PackageDict: one installed package, told apart from its namesakes by architecture.
A host can list one name twice: Debian multiarch installs ``libc6`` for amd64 and for
i386, Windows a 32-bit and a 64-bit build of one program (NetOrk/netork#2907).
"""
from napalm_device_types import models
from napalm_device_types.package_models import PackageDict
def test_architecture_is_the_one_optional_key() -> None:
assert PackageDict.__optional_keys__ == {"architecture"}
assert PackageDict.__required_keys__ == {
"name",
"version",
"installed",
"description",
"size",
"source",
}
def test_models_re_exports_it() -> None:
assert models.PackageDict is PackageDict