fix: import the typing names the annotations use

Dict, List and Optional were used in 30 annotations without an import;
from __future__ import annotations kept that from failing until
something resolved them (typing.get_type_hints raised NameError).

Closes #29
This commit is contained in:
Christian Manivong committed 2026-10-16 12:08:46 +02:00
1 parent 272bf21f8e
commit 8af7c52d82
2 files changed
+12 -1

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@ import logging
import re import re
import socket import socket
from shlex import quote as _shlex_quote from shlex import quote as _shlex_quote
from typing import Any from typing import Any, Dict, List, Optional
from netmiko import ConnectHandler from netmiko import ConnectHandler
from netmiko.exceptions import ( from netmiko.exceptions import (
+11
View File
@@ -180,3 +180,14 @@ def test_run_device_action_is_gone():
"_action_apt_update_upgrade", "_action_apt_update_upgrade",
): ):
assert not hasattr(LinuxDriver, name), name assert not hasattr(LinuxDriver, name), name
def test_every_annotation_resolves():
"""``Dict``, ``List`` and ``Optional`` were used without being imported (#29);
``from __future__ import annotations`` hid it until something resolved them."""
import inspect
import typing
for name, member in inspect.getmembers(LinuxDriver, inspect.isfunction):
if member.__module__ == "napalm_linux.linux":
typing.get_type_hints(member)