Skip to content

Commit cb989ef

Browse files
author
thomas
committed
loops to comprehension
1 parent 542f3d2 commit cb989ef

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

netbox/connection.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get(self, param, key=None, **kwargs):
8282
else:
8383
return resp_data
8484
else:
85-
return list
85+
return []
8686

8787
def put(self, params):
8888
if self.auth:
@@ -92,10 +92,8 @@ def put(self, params):
9292
def patch(self, params, key, **kwargs):
9393
if self.auth:
9494
raise exceptions.AuthException('With basic auth the API is not writable')
95-
body_data = {}
9695

97-
for k, v in kwargs.items():
98-
body_data.update({k: v})
96+
body_data = {key: value for (key, value) in kwargs.items()}
9997

10098
resp_ok, resp_status, resp_data = self.__request('PATCH', params=params, key=key, body=body_data)
10199

@@ -107,14 +105,10 @@ def patch(self, params, key, **kwargs):
107105
def post(self, params, required_fields, **kwargs):
108106
if self.auth:
109107
raise exceptions.AuthException('With basic auth the API is not writable')
110-
body_data = {}
111-
112-
for k, v in required_fields.items():
113-
body_data.update({k: v})
108+
body_data = {key: value for (key, value) in required_fields.items()}
114109

115110
if kwargs:
116-
for k, v in kwargs.items():
117-
body_data.update({k: v})
111+
body_data.update({key: value for (key, value) in kwargs.items()})
118112

119113
resp_ok, resp_status, resp_data = self.__request('POST', params=params, body=body_data)
120114

0 commit comments

Comments
 (0)