Skip to content

Commit d31c37a

Browse files
authored
Merge pull request #180 from amadeus4dev/method-to-function
Update methods that do not use their bound instance
2 parents 6607c21 + 001a672 commit d31c37a

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

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/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)

0 commit comments

Comments
 (0)