Skip to content

Commit e1da41e

Browse files
authored
Merge pull request #123 from joewesch/u/joewesch-122-exclude
Fixes exclude to work with lists
2 parents be82cec + 5b1b638 commit e1da41e

File tree

4 files changed

+77
-24
lines changed

4 files changed

+77
-24
lines changed

.github/workflows/ci.yml

+40-20
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ jobs:
1616
INVOKE_LOCAL: "True"
1717
steps:
1818
- name: "Check out repository code"
19-
uses: "actions/checkout@v2"
19+
uses: "actions/checkout@v4"
2020
- name: "Setup environment"
21-
uses: "networktocode/gh-action-setup-poetry-environment@v2"
21+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
22+
with:
23+
poetry-version: "1.8.5"
2224
- name: "Linting: black"
2325
run: "poetry run invoke black"
2426
mypy:
@@ -27,9 +29,11 @@ jobs:
2729
INVOKE_LOCAL: "True"
2830
steps:
2931
- name: "Check out repository code"
30-
uses: "actions/checkout@v2"
32+
uses: "actions/checkout@v4"
3133
- name: "Setup environment"
32-
uses: "networktocode/gh-action-setup-poetry-environment@v2"
34+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
35+
with:
36+
poetry-version: "1.8.5"
3337
- name: "Linting: mypy"
3438
run: "poetry run invoke mypy"
3539
bandit:
@@ -38,9 +42,11 @@ jobs:
3842
INVOKE_LOCAL: "True"
3943
steps:
4044
- name: "Check out repository code"
41-
uses: "actions/checkout@v2"
45+
uses: "actions/checkout@v4"
4246
- name: "Setup environment"
43-
uses: "networktocode/gh-action-setup-poetry-environment@v2"
47+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
48+
with:
49+
poetry-version: "1.8.5"
4450
- name: "Linting: bandit"
4551
run: "poetry run invoke bandit"
4652
pydocstyle:
@@ -49,9 +55,11 @@ jobs:
4955
INVOKE_LOCAL: "True"
5056
steps:
5157
- name: "Check out repository code"
52-
uses: "actions/checkout@v2"
58+
uses: "actions/checkout@v4"
5359
- name: "Setup environment"
54-
uses: "networktocode/gh-action-setup-poetry-environment@v2"
60+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
61+
with:
62+
poetry-version: "1.8.5"
5563
- name: "Linting: pydocstyle"
5664
run: "poetry run invoke pydocstyle"
5765
flake8:
@@ -60,9 +68,11 @@ jobs:
6068
INVOKE_LOCAL: "True"
6169
steps:
6270
- name: "Check out repository code"
63-
uses: "actions/checkout@v2"
71+
uses: "actions/checkout@v4"
6472
- name: "Setup environment"
65-
uses: "networktocode/gh-action-setup-poetry-environment@v2"
73+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
74+
with:
75+
poetry-version: "1.8.5"
6676
- name: "Linting: flake8"
6777
run: "poetry run invoke flake8"
6878
yamllint:
@@ -71,9 +81,11 @@ jobs:
7181
INVOKE_LOCAL: "True"
7282
steps:
7383
- name: "Check out repository code"
74-
uses: "actions/checkout@v2"
84+
uses: "actions/checkout@v4"
7585
- name: "Setup environment"
76-
uses: "networktocode/gh-action-setup-poetry-environment@v2"
86+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
87+
with:
88+
poetry-version: "1.8.5"
7789
- name: "Linting: yamllint"
7890
run: "poetry run invoke yamllint"
7991
pylint:
@@ -94,9 +106,13 @@ jobs:
94106
INVOKE_LOCAL: "True"
95107
steps:
96108
- name: "Check out repository code"
97-
uses: "actions/checkout@v2"
109+
uses: "actions/checkout@v4"
98110
- name: "Setup environment"
99-
uses: "networktocode/gh-action-setup-poetry-environment@v2"
111+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
112+
with:
113+
poetry-version: "1.8.5"
114+
# Default install options is "--only dev", but we need to install all dependencies
115+
poetry-install-options: ""
100116
- name: "Linting: Pylint"
101117
run: "poetry run invoke pylint"
102118
pytest:
@@ -112,9 +128,13 @@ jobs:
112128
INVOKE_LOCAL: "True"
113129
steps:
114130
- name: "Check out repository code"
115-
uses: "actions/checkout@v2"
131+
uses: "actions/checkout@v4"
116132
- name: "Setup environment"
117-
uses: "networktocode/gh-action-setup-poetry-environment@v2"
133+
uses: "networktocode/gh-action-setup-poetry-environment@v6"
134+
with:
135+
poetry-version: "1.8.5"
136+
# Default install options is "--only dev", but we need to install all dependencies
137+
poetry-install-options: ""
118138
- name: "Run Tests"
119139
run: "poetry run invoke pytest"
120140
publish_gh:
@@ -125,9 +145,9 @@ jobs:
125145
if: "startsWith(github.ref, 'refs/tags/v')"
126146
steps:
127147
- name: "Check out repository code"
128-
uses: "actions/checkout@v2"
148+
uses: "actions/checkout@v4"
129149
- name: "Set up Python"
130-
uses: "actions/setup-python@v2"
150+
uses: "actions/setup-python@v5"
131151
with:
132152
python-version: "3.9"
133153
- name: "Install Python Packages"
@@ -154,9 +174,9 @@ jobs:
154174
if: "startsWith(github.ref, 'refs/tags/v')"
155175
steps:
156176
- name: "Check out repository code"
157-
uses: "actions/checkout@v2"
177+
uses: "actions/checkout@v4"
158178
- name: "Set up Python"
159-
uses: "actions/setup-python@v2"
179+
uses: "actions/setup-python@v5"
160180
with:
161181
python-version: "3.9"
162182
- name: "Install Python Packages"

jdiff/extract_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def extract_data_from_json(data: Union[Mapping, List], path: str = "*", exclude:
3030
Returns:
3131
Evaluated data, may be anything depending on JMESPath used.
3232
"""
33-
if exclude and isinstance(data, Dict):
33+
if exclude and isinstance(data, (Dict, List)):
3434
if not isinstance(exclude, list):
3535
raise ValueError(f"Exclude list must be defined as a list. You have {type(exclude)}")
3636
# exclude unwanted elements

tasks.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Tasks for use with Invoke."""
22
import os
33
import sys
4-
from distutils.util import strtobool
54
from invoke import task
65

76
try:
@@ -16,14 +15,19 @@ def is_truthy(arg):
1615
Examples:
1716
>>> is_truthy('yes')
1817
True
19-
2018
Args:
2119
arg (str): Truthy string (True values are y, yes, t, true, on and 1; false values are n, no,
2220
f, false, off and 0. Raises ValueError if val is anything else.
2321
"""
2422
if isinstance(arg, bool):
2523
return arg
26-
return bool(strtobool(arg))
24+
25+
val = str(arg).lower()
26+
if val in ("y", "yes", "t", "true", "on", "1"):
27+
return True
28+
if val in ("n", "no", "f", "false", "off", "0"):
29+
return False
30+
raise ValueError(f"Invalid truthy value: `{arg}`")
2731

2832

2933
PYPROJECT_CONFIG = toml.load("pyproject.toml")

tests/test_filter_parsers.py

+29
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,38 @@
2828
}
2929
},
3030
)
31+
exclude_filter_test_case_2 = (
32+
["interfaceStatistics"],
33+
[
34+
{
35+
"interfaces": {
36+
"Management1": {
37+
"name": "Management1",
38+
"interfaceStatus": "connected",
39+
"autoNegotiate": "success",
40+
"interfaceStatistics": {
41+
"inBitsRate": 3403.4362520883615,
42+
"inPktsRate": 3.7424095978179257,
43+
"outBitsRate": 16249.69114419833,
44+
"updateInterval": 300,
45+
"outPktsRate": 2.1111866059750692,
46+
},
47+
}
48+
}
49+
}
50+
],
51+
[
52+
{
53+
"interfaces": {
54+
"Management1": {"name": "Management1", "interfaceStatus": "connected", "autoNegotiate": "success"}
55+
}
56+
}
57+
],
58+
)
3159

3260
exclude_filter_tests = [
3361
exclude_filter_test_case_1,
62+
exclude_filter_test_case_2,
3463
]
3564

3665

0 commit comments

Comments
 (0)