Skip to content

Commit

Permalink
Merge pull request #1412 from Kircheneer/develop
Browse files Browse the repository at this point in the history
Type hints napalm.base and napalm.nxos
  • Loading branch information
mirceaulinic authored Apr 30, 2021
2 parents b2ee14f + 2c5f31d commit ab188ee
Show file tree
Hide file tree
Showing 22 changed files with 1,015 additions and 557 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
name: build
on: [push, pull_request]
jobs:
Expand Down Expand Up @@ -33,10 +33,14 @@ jobs:
run: |
pylama .
- name: Run type checker
run: |
mypy -p napalm --config-file mypy.ini
- name: Run Tests
run: |
py.test --cov=napalm --cov-report term-missing -vs --pylama
build_docs:
needs: std_tests
runs-on: ubuntu-latest
Expand Down
15 changes: 15 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ allow_redefinition = True
[mypy-napalm.base.*]
disallow_untyped_defs = True

[mypy-napalm.nxos.*]
disallow_untyped_defs = True

[mypy-napalm.eos.*]
ignore_errors = True

[mypy-napalm.ios.*]
ignore_errors = True

[mypy-napalm.nxapi_plumbing.*]
disallow_untyped_defs = True

[mypy-napalm.base.clitools.*]
ignore_errors = True

[mypy-napalm.base.test.*]
ignore_errors = True

Expand Down
4 changes: 3 additions & 1 deletion napalm/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import importlib

# NAPALM base
from typing import Type

from napalm.base.base import NetworkDriver
from napalm.base.exceptions import ModuleImportError
from napalm.base.mock import MockDriver
Expand All @@ -29,7 +31,7 @@
]


def get_network_driver(name, prepend=True):
def get_network_driver(name: str, prepend: bool = True) -> Type[NetworkDriver]:
"""
Searches for a class derived form the base NAPALM class NetworkDriver in a specific library.
The library name must repect the following pattern: napalm_[DEVICE_OS].
Expand Down
Loading

0 comments on commit ab188ee

Please sign in to comment.