Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type hints napalm.base and napalm.nxos #1412

Merged
merged 16 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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