Skip to content

Commit

Permalink
#184: Fix misc. linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Nov 4, 2020
1 parent 33193de commit ed8aa34
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
39 changes: 16 additions & 23 deletions datagateway_api/common/filter_order_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,22 @@ def merge_python_icat_limit_skip_filters(self):
limit filter and remove the skip filter from the instance
"""
log.info("Merging a PythonICATSkipFilter and PythonICATLimitFilter together")

if any(
isinstance(icat_filter, PythonICATSkipFilter)
for icat_filter in self.filters
) and any(
isinstance(icat_filter, PythonICATLimitFilter)
for icat_filter in self.filters
):
# Merge skip and limit filter into a single limit filter
for icat_filter in self.filters:
if isinstance(icat_filter, PythonICATSkipFilter):
skip_filter = icat_filter
request_skip_value = icat_filter.skip_value

if isinstance(icat_filter, PythonICATLimitFilter):
limit_filter = icat_filter

if skip_filter and limit_filter:
log.info("Merging skip filter with limit filter")
limit_filter.skip_value = skip_filter.skip_value
log.info("Removing skip filter from list of filters")
self.remove_filter(skip_filter)
log.debug("Filters: %s", self.filters)
skip_filter = None
limit_filter = None

for icat_filter in self.filters:
if isinstance(icat_filter, PythonICATSkipFilter):
skip_filter = icat_filter

if isinstance(icat_filter, PythonICATLimitFilter):
limit_filter = icat_filter

if skip_filter and limit_filter:
log.info("Merging skip filter with limit filter")
limit_filter.skip_value = skip_filter.skip_value
log.info("Removing skip filter from list of filters")
self.remove_filter(skip_filter)
log.debug("Filters: %s", self.filters)

def clear_python_icat_order_filters(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions datagateway_api/common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_session_id_from_auth_header():
args["Authorization"].split(" ") if args["Authorization"] is not None else ""
)
if auth_header == "":
raise MissingCredentialsError(f"No credentials provided in auth header")
raise MissingCredentialsError("No credentials provided in auth header")
if len(auth_header) != 2 or auth_header[0] != "Bearer":
raise AuthenticationError(
f" Could not authenticate consumer with auth header {auth_header}",
Expand All @@ -74,7 +74,7 @@ def is_valid_json(string):
:return: boolean representing if the string is valid JSON
"""
try:
json_object = json.loads(string)
json.loads(string)
except ValueError:
return False
except TypeError:
Expand Down
2 changes: 1 addition & 1 deletion datagateway_api/common/icat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_entity_by_id(
# Set query condition for the selected ID
id_condition = PythonICATWhereFilter.create_condition("id", "=", id_)

includes_value = "1" if return_related_entities == True else None
includes_value = "1" if return_related_entities else None
id_query = ICATQuery(
client, entity_type, conditions=id_condition, includes=includes_value,
)
Expand Down
2 changes: 1 addition & 1 deletion datagateway_api/src/swagger/apispec_flask_restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def parse_operations(resource, operations):
logging.getLogger(__name__).warning(
"Cannot load docstring for {}/{}".format(resource, method),
)
operations[method.lower()] = operation or dict()
operations[method.lower()] = operation or {}


class RestfulPlugin(apispec.BasePlugin):
Expand Down
4 changes: 2 additions & 2 deletions util/icat_db_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,8 @@ def generate_all(i, generators):
def main():
start_time = datetime.datetime.now()
generators = [generator() for generator in Generator.__subclasses__()]
TIERS = 7
for i in range(TIERS):
tiers = 7
for i in range(tiers):
generate_all(i, generators)

print(
Expand Down

0 comments on commit ed8aa34

Please sign in to comment.