chore: adopt the NAPALM driver standard
driver / standard (pull_request) Successful in 13s
driver / lint (pull_request) Successful in 11s
driver / types (pull_request) Successful in 43s
driver / test (3.10) (pull_request) Successful in 58s
driver / test (3.11) (pull_request) Successful in 48s
driver / test (3.12) (pull_request) Successful in 47s
driver / test (3.13) (pull_request) Successful in 39s
driver / lowest (pull_request) Successful in 24s
driver / security (pull_request) Successful in 1m2s
driver / build (pull_request) Successful in 25s
CI / driver (pull_request) Successful in 6m10s
driver / publish (pull_request) Skipped

- CI moves to .gitea/workflows/ci.yml and calls the shared driver workflow
  of NAPALM/driver-standard; .github/ is gone.
- napalm-device-types >=4.21.1 from PyPI (the README no longer installs
  it from git), py.typed, SPDX license string, setuptools>=77, version
  floors on the dev extra, Issues and Changelog links on git.netork.io.
- mypy strict for the package; napalm_bsd.base, napalm_bsd.freebsd and
  napalm_bsd.openbsd are exempt for now (28 errors, mostly getters typed
  as plain dicts rather than the device-types TypedDicts), recorded in the
  quality baseline with three complex parsers. parse.py is strict after a
  one-line annotation.
- Coverage floor 94 % (measured 94.63 %).
This commit is contained in:
Christian Manivong committed 2026-10-23 08:34:50 +02:00
1 parent 78576c225c
commit 121343ee51
8 files changed
+74 -55

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
jobs:
driver:
uses: NAPALM/driver-standard/.gitea/workflows/driver.yml@main
with:
standard-ref: main
secrets:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
-48
View File
@@ -1,48 +0,0 @@
name: CI
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install package with dev extras
run: |
python -m pip install --upgrade pip
# napalm-device-types lives in git.netork.io/NAPALM, not on PyPI: without this
# pip looks there, finds an unrelated 0.1.0 and the job dies before any test.
python -m pip install "napalm-device-types @ git+https://git.netork.io/NAPALM/napalm-device-types.git"
python -m pip install -e ".[dev]"
- name: Run unit tests
run: |
python -m pytest -q --tb=short
- name: Build wheel and sdist
run: |
python -m pip install build
python -m build
- name: Upload dist artifacts
# v4 refuses to run on Gitea ("not currently supported on GHES").
uses: actions/upload-artifact@v3
with:
name: dist-${{ matrix.python-version }}
path: dist/*
+7
View File
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- The drivers follow the NAPALM driver standard
(https://git.netork.io/NAPALM/driver-standard): CI on Gitea runs ruff, mypy, the
tests on Python 3.10–3.13 and at the lowest declared versions, bandit, pip-audit and
a build check, and a release tag publishes to PyPI. The package now ships `py.typed`.
Python 3.10 stays the floor. napalm-device-types now comes from PyPI, 4.21.1 or later.
### Security ### Security
- The SSH host key is verified (NetOrk/netork#1167). `open()` takes the key to expect from `optional_args["ssh_host_key"]` and refuses any other one before it logs in (`SshHostKeyMismatch`); without one it accepts the first key. Every key it sees goes to `optional_args["ssh_host_key_observer"]`. Replaces paramiko's `AutoAddPolicy`. Requires napalm-device-types 4.19.0; version 0.4.0. - The SSH host key is verified (NetOrk/netork#1167). `open()` takes the key to expect from `optional_args["ssh_host_key"]` and refuses any other one before it logs in (`SshHostKeyMismatch`); without one it accepts the first key. Every key it sees goes to `optional_args["ssh_host_key_observer"]`. Replaces paramiko's `AutoAddPolicy`. Requires napalm-device-types 4.19.0; version 0.4.0.
-1
View File
@@ -93,7 +93,6 @@ machine, also in `hrProcessorLoad`).
## Development ## Development
```bash ```bash
pip install "napalm-device-types @ git+https://git.netork.io/NAPALM/napalm-device-types.git"
pip install -e ".[dev]" pip install -e ".[dev]"
pytest pytest
``` ```
+1 -1
View File
@@ -295,7 +295,7 @@ def _socket(
def _unique(sockets: list[dict[str, Any] | None]) -> list[dict[str, Any]]: def _unique(sockets: list[dict[str, Any] | None]) -> list[dict[str, Any]]:
"""One entry per socket, the first process holding it, as ss reports it.""" """One entry per socket, the first process holding it, as ss reports it."""
seen: set[tuple] = set() seen: set[tuple[Any, ...]] = set()
result = [] result = []
for s in sockets: for s in sockets:
if s is None: if s is None:
View File
Whitespace-only changes.
+35 -5
View File
@@ -1,5 +1,5 @@
[build-system] [build-system]
requires = ["setuptools>=68", "wheel"] requires = ["setuptools>=77"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[project] [project]
@@ -8,7 +8,7 @@ version = "0.4.0"
description = "NAPALM drivers for FreeBSD and OpenBSD hosts via SSH" description = "NAPALM drivers for FreeBSD and OpenBSD hosts via SSH"
readme = "README.md" readme = "README.md"
requires-python = ">=3.10" requires-python = ">=3.10"
license = { text = "Apache-2.0" } license = "Apache-2.0"
authors = [ authors = [
{ name = "Christian Manivong", email = "christian@manivong.de" }, { name = "Christian Manivong", email = "christian@manivong.de" },
] ]
@@ -16,22 +16,23 @@ keywords = ["napalm", "network", "automation", "freebsd", "openbsd", "bsd", "ssh
classifiers = [ classifiers = [
"Development Status :: 3 - Alpha", "Development Status :: 3 - Alpha",
"Intended Audience :: System Administrators", "Intended Audience :: System Administrators",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent", "Operating System :: OS Independent",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: System :: Systems Administration", "Topic :: System :: Systems Administration",
"Typing :: Typed",
] ]
dependencies = [ dependencies = [
"napalm>=4.0", "napalm>=4.0",
"napalm-device-types>=4.19.0", # fixes: SnmpAgentMixin, EnsurePackageMixin "napalm-device-types>=4.21.1",
"paramiko>=5.0.0", # CVE-2026-44405 "paramiko>=5.0.0", # CVE-2026-44405
] ]
[project.optional-dependencies] [project.optional-dependencies]
dev = ["pytest", "pytest-cov", "ruff", "mypy"] dev = ["pytest>=8", "pytest-cov>=5", "mypy>=1.11", "ruff>=0.6"]
[project.entry-points."napalm.drivers"] [project.entry-points."napalm.drivers"]
freebsd = "napalm_bsd:FreeBSDDriver" freebsd = "napalm_bsd:FreeBSDDriver"
@@ -39,11 +40,16 @@ openbsd = "napalm_bsd:OpenBSDDriver"
[project.urls] [project.urls]
Repository = "https://git.netork.io/NAPALM/napalm-bsd" Repository = "https://git.netork.io/NAPALM/napalm-bsd"
Issues = "https://git.netork.io/NAPALM/napalm-bsd/issues"
Changelog = "https://git.netork.io/NAPALM/napalm-bsd/src/branch/main/CHANGELOG.md"
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
where = ["."] where = ["."]
include = ["napalm_bsd*"] include = ["napalm_bsd*"]
[tool.setuptools.package-data]
napalm_bsd = ["py.typed"]
[tool.ruff] [tool.ruff]
line-length = 100 line-length = 100
target-version = "py310" target-version = "py310"
@@ -54,3 +60,27 @@ select = ["E", "F", "I", "UP", "B"]
[tool.ruff.lint.per-file-ignores] [tool.ruff.lint.per-file-ignores]
# Recorded device output keeps its lines. # Recorded device output keeps its lines.
"tests/**" = ["E501"] "tests/**" = ["E501"]
[tool.mypy]
python_version = "3.10"
strict = true
# napalm itself is untyped, so every driver subclasses Any.
disallow_subclassing_any = false
[[tool.mypy.overrides]]
module = ["napalm.*", "paramiko.*"]
ignore_missing_imports = true
[[tool.mypy.overrides]]
# Not yet under strict mypy (quality baseline); may only shrink.
module = ["napalm_bsd.base", "napalm_bsd.freebsd", "napalm_bsd.openbsd"]
ignore_errors = true
[tool.pytest.ini_options]
testpaths = ["tests"]
[tool.coverage.run]
source = ["napalm_bsd"]
[tool.coverage.report]
fail_under = 94
+16
View File
@@ -0,0 +1,16 @@
{
"coverage_floor": 94.0,
"function_complexity": {
"napalm_bsd/parse.py::ifconfig": 21,
"napalm_bsd/parse.py::routes": 21,
"napalm_bsd/parse.py::users": 11
},
"function_lines": {},
"mypy_relaxed": [
"napalm_bsd.base",
"napalm_bsd.freebsd",
"napalm_bsd.openbsd"
],
"python_file_lines": {},
"untyped_public": []
}