Skip to content

Commit 6adc81a

Browse files
authored
Close #680 CI Update (#681)
* Remove python3.6 and python3.7 from CI * Adjustments for ansible-tests on 2.12 * Add python3.10 to CI * Update poetry * Add poetry run to commands * Update black and reformat files * Update packaging, pylint * Update antsibull * Remove 2.10 tests
1 parent 5967548 commit 6adc81a

File tree

82 files changed

+272
-12331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+272
-12331
lines changed

.github/workflows/main.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: [3.6, 3.7, 3.8, 3.9]
12+
python-version: ["3.8", "3.9", "3.10"]
1313
steps:
1414
- name: Checkout repo
1515
uses: actions/checkout@v2
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
python-version: ${{ matrix.python-version }}
2020
- name: Install and configure Poetry
21-
uses: snok/install-poetry@v1.1.1
21+
uses: snok/install-poetry@v1
2222
with:
2323
virtualenvs-create: false
2424
- name: Install Python packages
@@ -28,15 +28,15 @@ jobs:
2828
ansible-galaxy collection build .
2929
ansible-galaxy collection install netbox*.tar.gz -p /home/runner/.ansible/collections
3030
- name: Run Black
31-
run: black . --check --diff
31+
run: poetry run black . --check --diff
3232
- name: Run Ansible Sanity tests
33-
run: ansible-test sanity -v --requirements --python ${{ matrix.python-version }} --skip-test pep8 plugins/
33+
run: poetry run ansible-test sanity -v --requirements --python ${{ matrix.python-version }} --skip-test pep8 plugins/
3434
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
3535
- name: Run Ansible Unit tests
36-
run: ansible-test units -vvv --coverage --python ${{ matrix.python-version }}
36+
run: poetry run ansible-test units -vvv --coverage --python ${{ matrix.python-version }}
3737
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
3838
- name: Run Ansible Coverage
39-
run: ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing
39+
run: poetry run ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing
4040
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
4141
integration:
4242
runs-on: ubuntu-latest

docs/_extensions/pygments_lexer.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ class AnsibleOutputPrimaryLexer(RegexLexer):
7070
# #########################################
7171
# # BEGIN: states from JSON lexer #########
7272
# #########################################
73-
"whitespace": [(r"\s+", token.Text),],
73+
"whitespace": [
74+
(r"\s+", token.Text),
75+
],
7476
# represents a simple terminal value
7577
"simplevalue": [
7678
(r"(true|false|null)\b", token.Keyword.Constant),

plugins/inventory/nb_inventory.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -478,26 +478,36 @@ def group_extractors(self):
478478
# Locations were added in 2.11 replacing rack-groups.
479479
if self.api_version >= version.parse("2.11"):
480480
extractors.update(
481-
{"location": self.extract_location,}
481+
{
482+
"location": self.extract_location,
483+
}
482484
)
483485
else:
484486
extractors.update(
485-
{"rack_group": self.extract_rack_group,}
487+
{
488+
"rack_group": self.extract_rack_group,
489+
}
486490
)
487491

488492
if self.services:
489493
extractors.update(
490-
{"services": self.extract_services,}
494+
{
495+
"services": self.extract_services,
496+
}
491497
)
492498

493499
if self.interfaces:
494500
extractors.update(
495-
{"interfaces": self.extract_interfaces,}
501+
{
502+
"interfaces": self.extract_interfaces,
503+
}
496504
)
497505

498506
if self.interfaces or self.dns_name or self.ansible_host_dns_name:
499507
extractors.update(
500-
{"dns_name": self.extract_dns_name,}
508+
{
509+
"dns_name": self.extract_dns_name,
510+
}
501511
)
502512

503513
return extractors
@@ -1288,7 +1298,7 @@ def fetch_api_docs(self):
12881298
try:
12891299
status = self._fetch_information(self.api_endpoint + "/api/status")
12901300
netbox_api_version = ".".join(status["netbox-version"].split(".")[:2])
1291-
except:
1301+
except Exception:
12921302
netbox_api_version = 0
12931303

12941304
tmp_dir = os.path.split(DEFAULT_LOCAL_TMP)[0]
@@ -1297,7 +1307,7 @@ def fetch_api_docs(self):
12971307
try:
12981308
with open(tmp_file) as file:
12991309
openapi = json.load(file)
1300-
except:
1310+
except Exception:
13011311
openapi = {}
13021312

13031313
cached_api_version = openapi.get("info", {}).get("version")
@@ -1725,7 +1735,8 @@ def main(self):
17251735
elif getattr(self, "site_group_names", None) and host.get("site"):
17261736
# Add host to site group when host is NOT assigned to a location
17271737
self.inventory.add_host(
1728-
group=self.site_group_names[host["site"]["id"]], host=hostname,
1738+
group=self.site_group_names[host["site"]["id"]],
1739+
host=hostname,
17291740
)
17301741

17311742
def parse(self, inventory, loader, path, cache=True):
@@ -1753,7 +1764,7 @@ def parse(self, inventory, loader, path, cache=True):
17531764
self.fetch_all = self.get_option("fetch_all")
17541765
self.headers = {
17551766
"User-Agent": "ansible %s Python %s"
1756-
% (ansible_version, python_version.split(" ")[0]),
1767+
% (ansible_version, python_version.split(" ", maxsplit=1)[0]),
17571768
"Content-type": "application/json",
17581769
}
17591770
self.cert = self.get_option("cert")

plugins/module_utils/netbox_utils.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -1019,19 +1019,23 @@ def _find_ids(self, data, user_query_params):
10191019
elif isinstance(v, list):
10201020
id_list = list()
10211021
for list_item in v:
1022-
if k in (
1023-
"regions",
1024-
"sites",
1025-
"roles",
1026-
"device_types",
1027-
"platforms",
1028-
"cluster_groups",
1029-
"clusters",
1030-
"contact_groups",
1031-
"tenant_groups",
1032-
"tenants",
1033-
"tags",
1034-
) and isinstance(list_item, str):
1022+
if (
1023+
k
1024+
in (
1025+
"regions",
1026+
"sites",
1027+
"roles",
1028+
"device_types",
1029+
"platforms",
1030+
"cluster_groups",
1031+
"clusters",
1032+
"contact_groups",
1033+
"tenant_groups",
1034+
"tenants",
1035+
"tags",
1036+
)
1037+
and isinstance(list_item, str)
1038+
):
10351039
temp_dict = {"slug": self._to_slug(list_item)}
10361040
elif isinstance(list_item, dict):
10371041
norm_data = self._normalize_data(list_item)
@@ -1378,7 +1382,7 @@ def check_mutually_exclusive(self, terms, module_parameters):
13781382
return results
13791383

13801384
def _check_required_if(self, spec, param=None):
1381-
""" ensure that parameters which conditionally required are present """
1385+
"""ensure that parameters which conditionally required are present"""
13821386
if spec is None:
13831387
return
13841388

plugins/modules/netbox_device_interface_template.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ def main():
123123
options=dict(
124124
device_type=dict(required=True, type="raw"),
125125
name=dict(required=True, type="str"),
126-
type=dict(required=True, type="str",),
126+
type=dict(
127+
required=True,
128+
type="str",
129+
),
127130
mgmt_only=dict(required=False, type="bool"),
128131
),
129132
),

plugins/modules/netbox_rack.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,27 @@ def main():
259259
"Wall-mounted cabinet",
260260
],
261261
),
262-
width=dict(required=False, type="int", choices=[10, 19, 21, 23,],),
262+
width=dict(
263+
required=False,
264+
type="int",
265+
choices=[
266+
10,
267+
19,
268+
21,
269+
23,
270+
],
271+
),
263272
u_height=dict(required=False, type="int"),
264273
desc_units=dict(required=False, type="bool"),
265274
outer_width=dict(required=False, type="int"),
266275
outer_depth=dict(required=False, type="int"),
267276
outer_unit=dict(
268-
required=False, type="str", choices=["Millimeters", "Inches",],
277+
required=False,
278+
type="str",
279+
choices=[
280+
"Millimeters",
281+
"Inches",
282+
],
269283
),
270284
comments=dict(required=False, type="str"),
271285
tags=dict(required=False, type="list", elements="raw"),

0 commit comments

Comments
 (0)