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 hinting #1476

Merged
merged 46 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
be14dc1
Add models and annotate NetworkDriver class with types
Kircheneer Mar 22, 2021
49791a9
Make tests pass by ignoring the annotations part of the arg spec
Kircheneer Mar 22, 2021
ba7b56f
Unpack optional in NXOSDevice.load_merge_candidate()
Kircheneer Mar 22, 2021
4df5ff2
Add lots of type hints, asserts and some abstract methods. Enable typ…
Kircheneer Mar 22, 2021
f4604a2
Solve type errors
Kircheneer Mar 27, 2021
aca0ebb
Add type checker to github actions
Kircheneer Mar 27, 2021
12f9da7
Specify mypy config file in github action
Kircheneer Mar 27, 2021
d8eaed7
Fix unused imports
Kircheneer Mar 27, 2021
8b8986b
Black formatting
Kircheneer Mar 27, 2021
80f9a98
Fix further pipeline problems
Kircheneer Mar 27, 2021
18907d3
Fix further pipeline errors
Kircheneer Mar 27, 2021
4ee35ba
Put type in quotes
Kircheneer Mar 27, 2021
97e0cae
Convert all typing_extensions try/except imports to pure typing_exten…
Kircheneer Mar 27, 2021
e373e03
Import TypedDict from typing_extensions in nxos.py
Kircheneer Mar 27, 2021
72c3e92
Ignore typing errors from napalm.iosxr_netconf
Kircheneer Apr 30, 2021
5ced7a3
Fix Callable import in mock.py
Kircheneer May 1, 2021
d52a2cb
Add models and annotate NetworkDriver class with types
Kircheneer Mar 22, 2021
066da2d
Make tests pass by ignoring the annotations part of the arg spec
Kircheneer Mar 22, 2021
67aef96
Add lots of type hints, asserts and some abstract methods. Enable typ…
Kircheneer Mar 22, 2021
39b6348
Solve type errors
Kircheneer Mar 27, 2021
c528848
Add type checker to github actions
Kircheneer Mar 27, 2021
d6ed6e2
Fix unused imports
Kircheneer Mar 27, 2021
ce4962c
Black formatting
Kircheneer Mar 27, 2021
3f4c6ad
Fix further pipeline problems
Kircheneer Mar 27, 2021
91dd630
Fix further pipeline errors
Kircheneer Mar 27, 2021
229820f
Convert all typing_extensions try/except imports to pure typing_exten…
Kircheneer Mar 27, 2021
3d09940
Import TypedDict from typing_extensions in nxos.py
Kircheneer Mar 27, 2021
53d7995
Fix Callable import in mock.py
Kircheneer May 1, 2021
10c0c38
Black
Kircheneer Jun 4, 2021
f7c36a0
Black
Kircheneer Jun 4, 2021
37e409a
Black
Kircheneer Jul 25, 2021
81c7a44
Fix linter issues
Kircheneer Jul 25, 2021
5c38927
Fix MyPy issues
Kircheneer Jul 25, 2021
f74e05f
Remove unused import
Kircheneer Jul 25, 2021
47b93ae
Solve type errors
Kircheneer Mar 27, 2021
431ebf4
Add type checker to github actions
Kircheneer Mar 27, 2021
4485899
Fix MyPy issues
Kircheneer Jul 25, 2021
9260bfa
Fix pylama issues
Kircheneer Feb 11, 2022
3bc3ed8
Remove future import.
Kircheneer Feb 11, 2022
a978096
Bump pytest-pythonpath from 0.7.3 to 0.7.4
dependabot[bot] Feb 10, 2022
92119dc
Fix outstanding Mypy errors
Kircheneer Feb 12, 2022
4e675ff
Merge branch 'develop' of https://github.com/napalm-automation/napalm…
Kircheneer Feb 12, 2022
6731176
Fix new type errors from develop rebase.
Kircheneer Feb 12, 2022
ee7e0bb
Re-add new type checking requirements to dev-requirements.
Kircheneer Feb 12, 2022
8c324ef
Apply black.
Kircheneer Feb 12, 2022
e4061c6
Elaborate on assert statement supporting Mypy in convert helper funct…
Kircheneer Feb 12, 2022
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
18 changes: 18 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ 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.iosxr_netconf.*]
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