Skip to content

Commit 3ac1f5f

Browse files
committed
fix all lint issues
1 parent ad338e8 commit 3ac1f5f

14 files changed

+36
-39
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ stages:
44
- "lint"
55
- "test"
66

7-
if: "type IN (pull_request)" # Add in "branch" as an option if desired for branch testing as well
7+
if: "type IN (pull_request)" # Add in "branch" as an option if desired for branch testing as well
88
language: "python"
99
services:
1010
- "docker"
@@ -30,7 +30,7 @@ jobs:
3030
- "pip install invoke toml"
3131
script:
3232
- "invoke black"
33-
- "invoke bandit" # Bandit fails to function on > Py3.8 https://github.com/PyCQA/bandit/issues/639
33+
- "invoke bandit" # Bandit fails to function on > Py3.8 https://github.com/PyCQA/bandit/issues/639
3434
# - "invoke pydocstyle"
3535
- "invoke flake8"
3636
- "invoke yamllint"

netcompare/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"Diff evaluator."
1+
"""Diff evaluator."""
22
import re
33
import sys
44
from collections import defaultdict

netcompare/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"Library wrapper for output parsing."
1+
"""Library wrapper for output parsing."""
22
import re
33
from typing import Mapping, List, Union
44
import jmespath

netcompare/utils/filter_parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"Filtering parsing."
1+
"""Filtering parsing."""
22
from typing import Mapping, List
33

44

netcompare/utils/flatten.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"Flatten multi-nested list."
1+
"""Flatten multi-nested list."""
22
from typing import List, Generator
33

44

netcompare/utils/jmspath_parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"JMSPath expresion parsers."
1+
"""JMSPath expresion parsers."""
22
import re
33

44

netcompare/utils/refkey.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
"""Reference key utilities."""
12
from typing import Mapping, List
23

34

45
def keys_cleaner(wanted_reference_keys: Mapping) -> List[Mapping]:
5-
"""
6-
Get every required reference key from output.
7-
"""
6+
"""Get every required reference key from output."""
87
if isinstance(wanted_reference_keys, list):
98
return wanted_reference_keys
109

11-
elif isinstance(wanted_reference_keys, dict):
12-
my_keys_list = list()
10+
if isinstance(wanted_reference_keys, dict):
11+
my_keys_list = []
1312

1413
if isinstance(wanted_reference_keys, dict):
1514
for key in wanted_reference_keys.keys():
@@ -21,12 +20,12 @@ def keys_cleaner(wanted_reference_keys: Mapping) -> List[Mapping]:
2120

2221
return my_keys_list
2322

23+
return None
24+
2425

2526
def keys_values_zipper(list_of_reference_keys: List, wanted_value_with_key: List) -> List:
26-
"""
27-
Build dictionary zipping keys with relative values.
28-
"""
29-
final_result = list()
27+
"""Build dictionary zipping keys with relative values."""
28+
final_result = []
3029

3130
if len(list_of_reference_keys) != len(wanted_value_with_key):
3231
raise ValueError("Keys len != from Values len")
@@ -38,10 +37,7 @@ def keys_values_zipper(list_of_reference_keys: List, wanted_value_with_key: List
3837

3938

4039
def associate_key_of_my_value(paths: str, wanted_value: List) -> List:
41-
"""
42-
Associate each key defined in path to every value found in output.
43-
"""
44-
40+
"""Associate each key defined in path to every value found in output."""
4541
# global.peers.*.[is_enabled,is_up] / result.[*].state
4642
find_the_key_of_my_values = paths.split(".")[-1]
4743

@@ -53,10 +49,10 @@ def associate_key_of_my_value(paths: str, wanted_value: List) -> List:
5349
else:
5450
my_key_value_list = [find_the_key_of_my_values]
5551

56-
final_list = list()
52+
final_list = []
5753

5854
for items in wanted_value:
59-
temp_dict = dict()
55+
temp_dict = {}
6056

6157
if len(items) != len(my_key_value_list):
6258
raise ValueError("Key's value len != from value len")

tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ def rebuild(context):
100100

101101

102102
@task(help={"local": "Run locally or within the Docker container"})
103-
def pytest(context, local=INVOKE_LOCAL):
103+
def pytest(context, path=".", local=INVOKE_LOCAL):
104104
"""Run pytest test cases."""
105-
exec_cmd = "pytest"
105+
exec_cmd = f"pytest {path}"
106106
run_cmd(context, exec_cmd, local)
107107

108108

tests/test_diff_generator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
"""Diff generator unit tests."""
12
import pytest
2-
from .utility import load_json_file
33
from netcompare.evaluator import diff_generator
44
from netcompare.runner import extract_values_from_output
5+
from .utility import load_json_file
56

67

7-
assertion_failed_message = """Test output is different from expected output.
8+
ASSERTION_FAILED_MESSAGE = """Test output is different from expected output.
89
output: {output}
910
expected output: {expected_output}
1011
"""
@@ -69,4 +70,4 @@ def test_eval(filename, path, exclude):
6970
post_value = extract_values_from_output(post_data, path, exclude)
7071
output = diff_generator(pre_value, post_value)
7172

72-
assert expected_output == output, assertion_failed_message.format(output=output, expected_output=expected_output)
73+
assert expected_output == output, ASSERTION_FAILED_MESSAGE.format(output=output, expected_output=expected_output)

tests/test_filter_parsers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from netcompare.utils.filter_parsers import exclude_filter
44

55

6-
assertion_failed_message = """Test output is different from expected output.
6+
ASSERTION_FAILED_MESSAGE = """Test output is different from expected output.
77
output: {output}
88
expected output: {expected_output}
99
"""
@@ -41,4 +41,4 @@
4141
@pytest.mark.parametrize("exclude, data, expected_output", exclude_filter_tests)
4242
def test_exclude_filter(exclude, data, expected_output):
4343
exclude_filter(data, exclude)
44-
assert expected_output == data, assertion_failed_message.format(output=data, expected_output=expected_output)
44+
assert expected_output == data, ASSERTION_FAILED_MESSAGE.format(output=data, expected_output=expected_output)

0 commit comments

Comments
 (0)