fix(packages): architecture is PackageDict's optional key, left out when unnamed (#14)
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 18s
driver / lowest (pull_request) Successful in 33s
driver / types (pull_request) Successful in 1m7s
driver / test (3.13) (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m14s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 59s
CI / driver (pull_request) Successful in 1m50s
driver / publish (pull_request) Skipped

napalm-device-types 4.59.0 declares architecture as an optional key of
PackageDict. WindowsPackageDict redeclared it as required, which strict
mypy refuses for a subclass. It now inherits the key and leaves it out
of a program whose Uninstall key names none, instead of writing "".
The floor is napalm-device-types 4.59.0.
This commit is contained in:
Christian Manivong committed 2026-12-05 06:52:34 +01:00
1 parent 61bbf91e32
commit 9b9fd261bd
4 files changed
+42 -6

No files matched your search

+19
View File
@@ -121,3 +121,22 @@ def test_an_empty_answer_has_no_packages(answer):
d = WindowsDriver("win01", "admin", "secret")
d._transport = FakeTransport(answer)
assert d.get_packages() == []
def test_architecture_is_the_contract_s_optional_key():
"""``PackageDict.architecture`` (napalm-device-types 4.59.0) is inherited, not
redeclared: a subclass may not make the contract's optional key required."""
assert "architecture" in mod.WindowsPackageDict.__optional_keys__
@pytest.mark.parametrize("arch", [None, ""])
def test_a_program_without_an_architecture_leaves_it_out(arch):
reading = _reading()
git = next(e for e in reading if e.get("name") == "Git")
if arch is None:
del git["arch"]
else:
git["arch"] = arch
packages = _packages(reading)
assert "architecture" not in next(p for p in packages if p["name"] == "Git")
assert [p["name"] for p in packages] == sorted((p["name"] for p in packages), key=str.lower)