diff --git a/lib/galaxy/authnz/managers.py b/lib/galaxy/authnz/managers.py index 07ac51f4f809..97bfdebe0c04 100644 --- a/lib/galaxy/authnz/managers.py +++ b/lib/galaxy/authnz/managers.py @@ -67,7 +67,7 @@ def _parse_oidc_config(self, config_file): if root.tag != "OIDC": raise etree.ParseError( "The root element in OIDC_Config xml file is expected to be `OIDC`, " - "found `{}` instead -- unable to continue.".format(root.tag) + f"found `{root.tag}` instead -- unable to continue." ) for child in root: if child.tag != "Setter": @@ -79,7 +79,7 @@ def _parse_oidc_config(self, config_file): if "Property" not in child.attrib or "Value" not in child.attrib or "Type" not in child.attrib: log.error( "Could not find the node attributes `Property` and/or `Value` and/or `Type`;" - " found these attributes: `{}`; skipping this node.".format(child.attrib) + f" found these attributes: `{child.attrib}`; skipping this node." ) continue try: @@ -110,7 +110,7 @@ def _parse_oidc_backends_config(self, config_file): if root.tag != "OIDC": raise etree.ParseError( "The root element in OIDC config xml file is expected to be `OIDC`, " - "found `{}` instead -- unable to continue.".format(root.tag) + f"found `{root.tag}` instead -- unable to continue." ) for child in root: if child.tag != "provider": diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 894c700e50b6..0641dba25c55 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -604,7 +604,7 @@ def calculate_user_disk_usage_statements(user_id, quota_source_map, for_sqlite=F ) if for_sqlite: # hacky alternative for older sqlite - statement = """ + statement = f""" WITH new (user_id, quota_source_label, disk_usage) AS ( VALUES(:id, :label, ({label_usage})) ) @@ -614,9 +614,7 @@ def calculate_user_disk_usage_statements(user_id, quota_source_map, for_sqlite=F LEFT JOIN user_quota_source_usage AS old ON new.user_id = old.user_id AND new.quota_source_label = old.quota_source_label -""".format( - label_usage=label_usage - ) +""" else: statement = f""" INSERT INTO user_quota_source_usage(user_id, quota_source_label, disk_usage) @@ -996,11 +994,7 @@ def calculate_disk_usage_default_source(self, object_store): exclude_objectstore_ids = quota_source_map.default_usage_excluded_ids() default_cond = "dataset.object_store_id IS NULL OR" if default_quota_enabled and exclude_objectstore_ids else "" default_usage_dataset_condition = ( - ( - "AND ( {default_cond} dataset.object_store_id NOT IN :exclude_object_store_ids )".format( - default_cond=default_cond, - ) - ) + (f"AND ( {default_cond} dataset.object_store_id NOT IN :exclude_object_store_ids )") if exclude_objectstore_ids else "" ) diff --git a/lib/galaxy/quota/__init__.py b/lib/galaxy/quota/__init__.py index dfe9ba4acb22..b78fa0e57aa3 100644 --- a/lib/galaxy/quota/__init__.py +++ b/lib/galaxy/quota/__init__.py @@ -179,16 +179,14 @@ def _default_unregistered_quota(self, quota_source_label): def _default_quota(self, default_type, quota_source_label): label_condition = "IS NULL" if quota_source_label is None else "= :label" query = text( - """ + f""" SELECT bytes FROM quota as default_quota LEFT JOIN default_quota_association on default_quota.id = default_quota_association.quota_id WHERE default_quota_association.type = :default_type AND default_quota.deleted != :is_true AND default_quota.quota_source_label {label_condition} -""".format( - label_condition=label_condition - ) +""" ) conn = self.sa_session.connection() diff --git a/lib/galaxy/web/framework/middleware/error.py b/lib/galaxy/web/framework/middleware/error.py index e94a73894461..99b4c8654c24 100644 --- a/lib/galaxy/web/framework/middleware/error.py +++ b/lib/galaxy/web/framework/middleware/error.py @@ -467,7 +467,7 @@ def send_report(rep, exc_data, html=True): def error_template(head_html, exception, extra): - return """ + return f""" @@ -476,7 +476,7 @@ def error_template(head_html, exception, extra): .content {{ max-width: 720px; margin: auto; margin-top: 50px; }} Internal Server Error - {} + {head_html}
@@ -484,16 +484,14 @@ def error_template(head_html, exception, extra):

Galaxy was unable to successfully complete your request

-

{}

+

{exception}

This may be an intermittent problem due to load or other unpredictable factors, reloading the page may address the problem. - {} + {extra}
- """.format( - head_html, exception, extra - ) + """ def make_error_middleware(app, global_conf, **kw): diff --git a/lib/galaxy/webapps/galaxy/api/cloudauthz.py b/lib/galaxy/webapps/galaxy/api/cloudauthz.py index fb0227f1f906..f6813c1cf1f1 100644 --- a/lib/galaxy/webapps/galaxy/api/cloudauthz.py +++ b/lib/galaxy/webapps/galaxy/api/cloudauthz.py @@ -93,11 +93,11 @@ def create(self, trans, payload, **kwargs): * status: HTTP response code * message: A message complementary to the response code. """ - msg_template = f"Rejected user `{str(trans.user.id)}`'s request to create cloudauthz config because of {{}}." + msg_template = f"Rejected user `{trans.user.id}`'s request to create cloudauthz config because of {{}}." if not isinstance(payload, dict): raise ActionInputError( "Invalid payload data type. The payload is expected to be a dictionary, but " - "received data of type `{}`.".format(str(type(payload))) + f"received data of type `{type(payload)}`." ) missing_arguments = [] @@ -116,7 +116,7 @@ def create(self, trans, payload, **kwargs): if len(missing_arguments) > 0: log.debug(msg_template.format(f"missing required config {missing_arguments}")) raise RequestParameterMissingException( - "The following required arguments are missing in the payload: " "{}".format(missing_arguments) + f"The following required arguments are missing in the payload: {missing_arguments}" ) description = payload.get("description", "") @@ -200,9 +200,7 @@ def delete(self, trans, encoded_authz_id, **kwargs): return view except Exception as e: log.exception( - msg_template.format( - "exception while deleting the cloudauthz record with " "ID: `{}`.".format(encoded_authz_id) - ) + msg_template.format(f"exception while deleting the cloudauthz record with ID: `{encoded_authz_id}`.") ) raise InternalServerError( "An unexpected error has occurred while responding to the DELETE request of the " @@ -270,9 +268,7 @@ def update(self, trans, encoded_authz_id, payload, **kwargs): raise e except Exception as e: log.exception( - msg_template.format( - "exception while updating the cloudauthz record with " "ID: `{}`.".format(encoded_authz_id) - ) + msg_template.format(f"exception while updating the cloudauthz record with ID: `{encoded_authz_id}`.") ) raise InternalServerError( "An unexpected error has occurred while responding to the PUT request of the "