Skip to content

Commit

Permalink
Enable flake8-logging-format rules in ruff, fix G003 and G010 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Oct 25, 2023
1 parent c5ad97c commit 544769d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
20 changes: 8 additions & 12 deletions lib/galaxy/jobs/runners/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,8 @@ def __get_run_as_user_id(self):
return int(self.runner_params["k8s_run_as_user_id"])
except Exception:
log.warning(
'User ID passed for Kubernetes runner needs to be an integer or "$uid", value '
+ self.runner_params["k8s_run_as_user_id"]
+ " passed is invalid"
'User ID passed for Kubernetes runner needs to be an integer or "$uid", value %s passed is invalid',
self.runner_params["k8s_run_as_user_id"],
)
return None
return None
Expand All @@ -269,9 +268,8 @@ def __get_run_as_group_id(self):
return int(self.runner_params["k8s_run_as_group_id"])
except Exception:
log.warning(
'Group ID passed for Kubernetes runner needs to be an integer or "$gid", value '
+ self.runner_params["k8s_run_as_group_id"]
+ " passed is invalid"
'Group ID passed for Kubernetes runner needs to be an integer or "$gid", value %s passed is invalid',
self.runner_params["k8s_run_as_group_id"],
)
return None

Expand All @@ -284,9 +282,8 @@ def __get_supplemental_group(self):
return int(self.runner_params["k8s_supplemental_group_id"])
except Exception:
log.warning(
'Supplemental group passed for Kubernetes runner needs to be an integer or "$gid", value '
+ self.runner_params["k8s_supplemental_group_id"]
+ " passed is invalid"
'Supplemental group passed for Kubernetes runner needs to be an integer or "$gid", value %s passed is invalid',
self.runner_params["k8s_supplemental_group_id"],
)
return None
return None
Expand All @@ -297,9 +294,8 @@ def __get_fs_group(self):
return int(self.runner_params["k8s_fs_group_id"])
except Exception:
log.warning(
'FS group passed for Kubernetes runner needs to be an integer or "$gid", value '
+ self.runner_params["k8s_fs_group_id"]
+ " passed is invalid"
'FS group passed for Kubernetes runner needs to be an integer or "$gid", value %s passed is invalid',
self.runner_params["k8s_fs_group_id"],
)
return None
return None
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/metadata/set_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def set_meta(new_dataset_instance, file_dict):
if not is_celery_task:
error_desc = "Failed to find tool_stdout or tool_stderr for this job, cannot collect metadata"
error_extra = f"Working dir contents [{wdc}], output directory contents [{odc}]"
log.warn(f"{error_desc}. {error_extra}")
log.warning(f"{error_desc}. {error_extra}")
raise Exception(error_desc)
else:
tool_stdout = tool_stderr = b""
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/visualization/plugins/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ def parse_tests(self, xml_tree_list):
test_result = test_elem.text.strip() if test_elem.text else None
if not test_type or not test_result:
log.warning(
"Skipping test. Needs both type attribute and text node to be parsed: "
+ f"{test_type}, {test_elem.text}"
"Skipping test. Needs both type attribute and text node to be parsed: %s, %s",
test_type,
test_elem.text,
)
continue
test_result = test_result.strip()
Expand Down
7 changes: 5 additions & 2 deletions lib/galaxy/visualization/plugins/resource_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ def parse_config(self, trans, param_config_dict, query_params):

except Exception as exception:
log.warning(
"Exception parsing visualization param from query: "
+ f"{param_name}, {config_val}, ({str(type(exception))}) {str(exception)}"
"Exception parsing visualization param from query: %s, %s, (%s) %s",
param_name,
config_val,
type(exception),
exception,
)
config_val = None

Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,17 @@ types-requests = "*"
types-six = "*"

[tool.ruff]
select = ["E", "F", "B", "UP"]
# Enable: pycodestyle errors (E), Pyflakes (F), flake8-bugbear (B),
# flake8-logging-format (G) and pyupgrade (UP)
select = ["E", "F", "B", "G", "UP"]
target-version = "py37"
# Exceptions:
# B008 Do not perform function calls in argument defaults (for FastAPI Depends and Body)
# B9 flake8-bugbear opinionated warnings
# E402 module level import not at top of file # TODO, we would like to improve this.
# E501 is line length (delegated to black)
ignore = ["B008", "B9", "E402", "E501"]
# G* are TODOs
ignore = ["B008", "B9", "E402", "E501", "G001", "G002", "G004", "G201"]
exclude = [
"lib/tool_shed/test/test_data/repos"
]
Expand Down

0 comments on commit 544769d

Please sign in to comment.