Skip to content

Commit

Permalink
#155: Put longer strings onto multiple lines to keep with 88 charact…
Browse files Browse the repository at this point in the history
…er line length

- A couple have been left alone as they're only 1/2 characters over 88 (as defined by Black). It seemed better to keep them on a single line for readability reasons
  • Loading branch information
MRichards99 committed Aug 13, 2020
1 parent 4aff02d commit 0f67fc7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
6 changes: 3 additions & 3 deletions common/database/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
PythonICATIncludeFilter as IncludeFilter,
)
else:
# TODO - Check this way of string formatting works
raise ApiError(
"Cannot select which implementation of filters to import, check the config file"
" has a valid backend type"
Expand All @@ -59,8 +58,9 @@

def requires_session_id(method):
"""
Decorator for database backend methods that makes sure a valid session_id is provided
It expects that session_id is the second argument supplied to the function
Decorator for database backend methods that makes sure a valid session_id is
provided. It expects that session_id is the second argument supplied to the function
:param method: The method for the backend operation
:raises AuthenticationError, if a valid session_id is not provided with the request
"""
Expand Down
20 changes: 10 additions & 10 deletions common/icat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def construct_icat_query(
includes=includes,
)
except ValueError:
# TODO - Convert once I've tested the other one
raise PythonICATError(
f"An issue has occurred while creating a Python ICAT Query object, suggesting an invalid argument"
"An issue has occurred while creating a Python ICAT Query object,"
" suggesting an invalid argument"
)

return query
Expand Down Expand Up @@ -193,9 +193,9 @@ def get_python_icat_entity_name(client, database_table_name):

# Raise a 400 if a valid entity cannot be found
if python_icat_entity_name is None:
# TODO - Change
raise BadRequestError(
f"Bad request made, cannot find {database_table_name} entity within Python ICAT"
f"Bad request made, cannot find {database_table_name} entity within Python"
" ICAT"
)

return python_icat_entity_name
Expand Down Expand Up @@ -248,9 +248,9 @@ def str_to_date_object(icat_attribute, data):
try:
data = datetime.strptime(data, accepted_date_format)
except ValueError:
# TODO - Change
raise BadRequestError(
f"Bad request made, the date entered is not in the correct format. Use the {accepted_date_format} format to submit dates to the API"
"Bad request made, the date entered is not in the correct format. Use"
f" the {accepted_date_format} format to submit dates to the API"
)

return data
Expand All @@ -275,17 +275,17 @@ def update_attributes(object, dictionary):
original_data_attribute, dictionary[key]
)
except AttributeError:
# TODO - Change
raise BadRequestError(
f"Bad request made, cannot find attribute '{key}' within the {object.BeanName} entity"
f"Bad request made, cannot find attribute '{key}' within the"
f" {object.BeanName} entity"
)

try:
setattr(object, key, dictionary[key])
except AttributeError:
# TODO - Change
raise BadRequestError(
f"Bad request made, cannot modify attribute '{key}' within the {object.BeanName} entity"
f"Bad request made, cannot modify attribute '{key}' within the"
f" {object.BeanName} entity"
)

object.update()
Expand Down
1 change: 0 additions & 1 deletion common/logger_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from common.config import config

# TODO - Test logging works with trailing commas
log_level = "DEBUG"
LOG_FILE_NAME = Path(__file__).parent.parent / "logs.log"
logger_config = {
Expand Down
4 changes: 2 additions & 2 deletions test/test_database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
PythonICATIncludeFilter as IncludeFilter,
)
else:
# TODO - Change
raise ApiError(
"Cannot select which implementation of filters to import, check the config file has a valid backend type"
"Cannot select which implementation of filters to import, check the config file"
" has a valid backend type"
)


Expand Down
8 changes: 4 additions & 4 deletions util/icat_db_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ def generate_all(i, generators):
processes = []
for generator in generators:
if generator.tier == i:
# TODO - Change
print(
f"Adding {type(generator).__name__.replace('Generator', '') + 's'} of tier {generator.tier}"
f"Adding {type(generator).__name__.replace('Generator', '') + 's'} of"
f" tier {generator.tier}"
)
processes.append(Process(target=generator.generate))

Expand All @@ -699,9 +699,9 @@ def main():
for i in range(TIERS):
generate_all(i, generators)

# TODO - Change
print(
f"Added {sum(generator.amount for generator in generators)} entities in {datetime.datetime.now() - start_time}"
f"Added {sum(generator.amount for generator in generators)} entities in"
f" {datetime.datetime.now() - start_time}"
)


Expand Down

0 comments on commit 0f67fc7

Please sign in to comment.