Skip to content

Commit 89f833c

Browse files
committed
Merge branch 'master' into update-old-libraries
2 parents ed58cec + d31c37a commit 89f833c

File tree

10 files changed

+27
-18
lines changed

10 files changed

+27
-18
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/errors.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def description(self):
3838

3939
# Determines the short description, printed after on the same line as the
4040
# error class name
41-
def short_description(self, response):
41+
@staticmethod
42+
def short_description(response):
4243
if hasattr(response, 'status_code') and response.status_code:
4344
return '[{0}]'.format(response.status_code)
4445
else:
@@ -56,7 +57,8 @@ def long_description(self, response):
5657
return message
5758

5859
# Returns the description of a single error
59-
def error_description(self, response):
60+
@staticmethod
61+
def error_description(response):
6062
message = ''
6163
if 'error' in response.result:
6264
message += '\n{0}'.format(response.result['error'])
@@ -69,7 +71,8 @@ def errors_descriptions(self, response):
6971
return ''.join(messages)
7072

7173
# Returns the description of a single error in a multi error response
72-
def errors_description(self, error):
74+
@staticmethod
75+
def errors_description(error):
7376
message = '\n'
7477
if ('source' in error) and ('parameter' in error['source']):
7578
message += '[{0}] '.format(error['source']['parameter'])

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/mixins/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get(self, path, **params):
3939
'''
4040
return self.request('GET', path, params)
4141

42-
def post(self, path, params={}):
42+
def post(self, path, params=None):
4343
'''
4444
A helper function for making generic POST requests calls. It is used by
4545
every namespaced API POST method.

amadeus/mixins/pagination.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def __page(self, name, response):
3333
params
3434
)
3535

36-
def __page_number_for(self, name, response):
36+
@staticmethod
37+
def __page_number_for(name, response):
3738
try:
3839
url = response.result['meta']['links'][name]
3940
return url.split('page%5Boffset%5D=')[1].split('&')[0]

amadeus/mixins/parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def _detect_error(self, client):
1515
if error is not None:
1616
self.__raise_error(error, client)
1717

18-
def error_for(self, status_code, parsed): # noqa: C901
18+
@staticmethod # noqa: C901
19+
def error_for(status_code, parsed):
1920
if status_code is None:
2021
return NetworkError
2122
if status_code >= 500:

amadeus/mixins/validator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class Validator(object):
1414
# Checks a list of options for unrecognized keys and warns the user.
1515
# This is mainly used to provide a nice experience when users make a typo
1616
# in their arguments.
17-
def _warn_on_unrecognized_options(self, options, logger, valid_options):
17+
@staticmethod
18+
def _warn_on_unrecognized_options(options, logger, valid_options):
1819
for key in options:
1920
if (key in valid_options):
2021
continue
@@ -68,7 +69,8 @@ def __init_required(self, key, options):
6869
# Tries to find an option by string or symbol in the options hash and
6970
# in the environment variables.When it can not find it anywhere it
7071
# defaults to the provided default option.
71-
def __init_optional(self, key, options, defa_ult=None):
72+
@staticmethod
73+
def __init_optional(key, options, defa_ult=None):
7274
value = options.get(key, None)
7375
if (value is None):
7476
env_key = 'AMADEUS_{0}'.format(key.upper())

amadeus/namespaces/_travel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ def __init__(self, client):
1212
self.predictions = Predictions(client)
1313
self.trip_parser = TripParser(client)
1414

15-
def from_file(self, file):
15+
@staticmethod
16+
def from_file(file):
1617
return from_file(file)
1718

18-
def from_base64(self, base64):
19+
@staticmethod
20+
def from_base64(base64):
1921
return from_base64(base64)

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)