Skip to content

Commit 243208b

Browse files
author
Zach Moody
authored
Merge pull request #321 from digitalocean/fix-linter
Fix linter
2 parents f865d35 + 03b9586 commit 243208b

File tree

7 files changed

+19
-39
lines changed

7 files changed

+19
-39
lines changed

.github/workflows/py3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: pip install . black==19.10b0 pytest
2727

2828
- name: Run Linter
29-
run: black --diff pynetbox tests
29+
run: black --diff --check pynetbox tests
3030

3131
- name: Run Tests
3232
run: pytest

pynetbox/core/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def __init__(self, api):
149149
self.api = api
150150

151151
def __getattr__(self, name):
152-
return App(self.api, 'plugins/{}'.format(name))
152+
return App(self.api, "plugins/{}".format(name))
153153

154154
def installed_plugins(self):
155155
""" Returns raw response with installed plugins

pynetbox/core/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def list_parser(list_item):
281281

282282
def _endpoint_from_url(self, url):
283283
# Remove the base URL from the beginning
284-
url = url[len(self.api.base_url):]
284+
url = url[len(self.api.base_url) :]
285285
if url.startswith("/"):
286286
url = url[1:]
287287
app, name = urlsplit(url).path.split("/")[:2]

tests/test_api.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class ResponseHeadersWithVersion:
5252
ok = True
5353

5454
@patch(
55-
"requests.sessions.Session.get",
56-
return_value=ResponseHeadersWithVersion(),
55+
"requests.sessions.Session.get", return_value=ResponseHeadersWithVersion(),
5756
)
5857
def test_api_version(self, *_):
5958
api = pynetbox.api(host,)
@@ -64,8 +63,7 @@ class ResponseHeadersWithoutVersion:
6463
ok = True
6564

6665
@patch(
67-
"requests.sessions.Session.get",
68-
return_value=ResponseHeadersWithoutVersion(),
66+
"requests.sessions.Session.get", return_value=ResponseHeadersWithoutVersion(),
6967
)
7068
def test_api_version_not_found(self, *_):
7169
api = pynetbox.api(host,)
@@ -75,14 +73,14 @@ def test_api_version_not_found(self, *_):
7573
class ApiStatusTestCase(unittest.TestCase):
7674
class ResponseWithStatus:
7775
ok = True
76+
7877
def json(self):
7978
return {
8079
"netbox-version": "0.9.9",
8180
}
8281

8382
@patch(
84-
"requests.sessions.Session.get",
85-
return_value=ResponseWithStatus(),
83+
"requests.sessions.Session.get", return_value=ResponseWithStatus(),
8684
)
8785
def test_api_status(self, *_):
8886
api = pynetbox.api(host,)

tests/test_app.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ class AppConfigTestCase(unittest.TestCase):
3636
"pynetbox.core.query.Request.get",
3737
return_value={
3838
"tables": {
39-
"DeviceTable": {
40-
"columns": [
41-
"name", "status", "tenant", "tags",
42-
],
43-
},
39+
"DeviceTable": {"columns": ["name", "status", "tenant", "tags",],},
4440
},
4541
},
4642
)
@@ -70,10 +66,7 @@ def test_custom_choices(self, *_):
7066

7167
@patch(
7268
"pynetbox.core.query.Request.get",
73-
return_value=[{
74-
"name": "test_plugin",
75-
"package": "netbox_test_plugin",
76-
}],
69+
return_value=[{"name": "test_plugin", "package": "netbox_test_plugin",}],
7770
)
7871
def test_installed_plugins(self, *_):
7972
api = pynetbox.api(host, **def_kwargs)

tests/test_dcim.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ def test_delete(self):
8989
return_value=Response(
9090
fixture="{}/{}.json".format(self.app, self.name[:-1])
9191
),
92-
) as mock, patch(
93-
"requests.sessions.Session.delete"
94-
) as delete:
92+
) as mock, patch("requests.sessions.Session.delete") as delete:
9593
ret = getattr(nb, self.name).get(1)
9694
self.assertTrue(ret.delete())
9795
mock.assert_called_with(
@@ -531,10 +529,7 @@ def test_get_circuit(self):
531529
"length_unit": None,
532530
}
533531
)
534-
with patch(
535-
"requests.sessions.Session.get",
536-
return_value=response_obj,
537-
) as mock:
532+
with patch("requests.sessions.Session.get", return_value=response_obj,) as mock:
538533
ret = getattr(nb, self.name).get(1)
539534
self.assertTrue(ret)
540535
self.assertTrue(isinstance(ret, self.ret))

tests/unit/test_response.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,14 @@ def test_serialize_string_tag_set(self):
7777
self.assertEqual(len(test["tags"]), 2)
7878

7979
def test_serialize_dict_tag_set(self):
80-
test_values = {"id": 123, "tags": [
81-
{
82-
"id": 1,
83-
"name": "foo",
84-
},
85-
{
86-
"id": 2,
87-
"name": "bar",
88-
},
89-
{
90-
"id": 3,
91-
"name": "baz",
92-
},
93-
]}
80+
test_values = {
81+
"id": 123,
82+
"tags": [
83+
{"id": 1, "name": "foo",},
84+
{"id": 2, "name": "bar",},
85+
{"id": 3, "name": "baz",},
86+
],
87+
}
9488
test = Record(test_values, None, None).serialize()
9589
self.assertEqual(len(test["tags"]), 3)
9690

0 commit comments

Comments
 (0)