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:
1 parent
272bf21f8e
commit
8af7c52d82
2 files changed
+12
-1
No files matched your search
@@ -23,7 +23,7 @@ import logging
|
||||
import re
|
||||
import socket
|
||||
from shlex import quote as _shlex_quote
|
||||
from typing import Any
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from netmiko import ConnectHandler
|
||||
from netmiko.exceptions import (
|
||||
|
||||
@@ -180,3 +180,14 @@ def test_run_device_action_is_gone():
|
||||
"_action_apt_update_upgrade",
|
||||
):
|
||||
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)
|
||||
Reference in new issue
Block a user