Skip to content

Commit d2262c6

Browse files
authored
Merge pull request #176 from amadeus4dev/update-typecheck
Replace type with isinstance
2 parents 379ee77 + 6a5b0d2 commit d2262c6

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

amadeus/booking/_flight_orders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ def post(self, flight, travelers):
1414
:raises amadeus.ResponseError: if the request could not be completed
1515
'''
1616
flight_offers = []
17-
if type(flight) is not list:
17+
if not isinstance(flight, list):
1818
flight_offers.append(flight)
1919
else:
2020
flight_offers.extend(flight)
2121
travelers_info = []
22-
if type(travelers) is not list:
22+
if not isinstance(travelers, list):
2323
travelers_info.append(travelers)
2424
else:
2525
travelers_info.extend(travelers)

amadeus/booking/_hotel_bookings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def post(self, hotel_offer_id, guests, payments):
1919
'''
2020
guests_info = []
2121
payment_info = []
22-
if type(guests) is not list:
22+
if not isinstance(guests, list):
2323
guests_info.append(guests)
2424
else:
2525
guests_info.extend(guests)
26-
if type(payments) is not list:
26+
if not isinstance(payments, list):
2727
payment_info.append(payments)
2828
else:
2929
payment_info.extend(payments)

amadeus/client/request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __build_http_request(self):
109109
# Adds HTTP override in Header for the list of paths required
110110
if self.path in Request.list_httpoverride:
111111
self.headers['X-HTTP-Method-Override'] = 'GET'
112-
if type(self.params) is dict:
112+
if isinstance(self.params, dict):
113113
return HTTPRequest(self.url, headers=self.headers, method='POST',
114114
data=json.dumps(self.params).encode())
115115
else:
@@ -142,12 +142,12 @@ def _urlencode(self, d):
142142

143143
# Flattens the hash keys, so page: { offset: 1 } becomes page[offet] = 1
144144
def _flatten_keys(self, d, key, out):
145-
if type(d) is not dict:
145+
if not isinstance(d, dict):
146146
raise TypeError('Only dicts can be encoded')
147147

148148
for k in d:
149149
keystr = k if not key else '[{}]'.format(k)
150-
if type(d[k]) is dict:
150+
if isinstance(d[k], dict):
151151
self._flatten_keys(d[k], str(key) + str(keystr), out)
152152
else:
153153
out['{}{}'.format(key, keystr)] = d[k]

amadeus/shopping/flight_offers/_pricing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def post(self, body, **params):
1717
'''
1818
url = '/v1/shopping/flight-offers/pricing?'
1919
flight_offers = []
20-
if type(body) is not list:
20+
if not isinstance(body, list):
2121
flight_offers.append(body)
2222
else:
2323
flight_offers.extend(body)

0 commit comments

Comments
 (0)