Skip to content

Add ruff and isort to make format and tox, add pre-commit config #1552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ lint: ## check style using tox and flake8 for Python 2 and Python 3
test: ## run tests with the default Python (faster than tox)
$(IN_VENV) pytest $(TESTS)

format: ## format Python code with black
format: ## format Python code with ruff, black and isort
$(IN_VENV) ruff format planemo tests
$(IN_VENV) isort planemo tests
$(IN_VENV) black planemo tests

quick-test: ## run quickest tests with the default Python
Expand Down
2 changes: 1 addition & 1 deletion planemo/commands/cmd_share_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from planemo.cli import command_function
from planemo.io import info

PLANEMO_TEST_VIEWER_URL_TEMPLATE = "http://galaxyproject.github.io/planemo/tool_test_viewer.html" "?test_data_url=%s"
PLANEMO_TEST_VIEWER_URL_TEMPLATE = "http://galaxyproject.github.io/planemo/tool_test_viewer.html?test_data_url=%s"


@click.command("share_test")
Expand Down
2 changes: 1 addition & 1 deletion planemo/commands/cmd_shed_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@click.option(
"--raw",
is_flag=True,
help="Do not attempt smart diff of XML to filter out attributes " "populated by the Tool Shed.",
help="Do not attempt smart diff of XML to filter out attributes populated by the Tool Shed.",
)
@options.report_xunit()
@command_function
Expand Down
2 changes: 1 addition & 1 deletion planemo/commands/cmd_shed_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@click.option(
"--from_workflow",
type=click.Path(exists=True, file_okay=True, resolve_path=True),
help=("Attempt to generate repository dependencies from specified " "workflow."),
help=("Attempt to generate repository dependencies from specified workflow."),
)
@click.option("--description", help="Specify repository description for .shed.yml.")
@click.option("--long_description", help="Specify repository long_description for .shed.yml.")
Expand Down
3 changes: 1 addition & 2 deletions planemo/commands/cmd_shed_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
is_flag=True,
default=False,
help=(
"Ensure .shed.yml files contain enough metadata for each repository "
"to allow automated creation and/or updates."
"Ensure .shed.yml files contain enough metadata for each repository to allow automated creation and/or updates."
),
)
@click.option(
Expand Down
2 changes: 1 addition & 1 deletion planemo/commands/cmd_shed_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
@click.option(
"--tar",
help="Specify a pre-existing tar file instead of automatically building " "one as part of this command.",
help="Specify a pre-existing tar file instead of automatically building one as part of this command.",
type=tar_path,
default=None,
)
Expand Down
2 changes: 1 addition & 1 deletion planemo/cwl/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if TYPE_CHECKING:
from planemo.cli import PlanemoCliContext

JSON_PARSE_ERROR_MESSAGE = "Failed to parse JSON from cwltool output [%s] " "in file [%s]. cwltool logs [%s]."
JSON_PARSE_ERROR_MESSAGE = "Failed to parse JSON from cwltool output [%s] in file [%s]. cwltool logs [%s]."


class CwlToolRunResponse(SuccessfulRunResponse):
Expand Down
2 changes: 1 addition & 1 deletion planemo/galaxy/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def get_output(self, output_id):
def download_output_to(self, ctx, dataset_details, output_directory, filename=None):
extension = dataset_details["file_ext"]
if filename is None:
local_filename = f'{sanitize_filename(dataset_details.get("cwl_file_name") or dataset_details.get("name"))}__{dataset_details["uuid"]}.{extension}'
local_filename = f"{sanitize_filename(dataset_details.get('cwl_file_name') or dataset_details.get('name'))}__{dataset_details['uuid']}.{extension}"
else:
local_filename = f"{filename}.{extension}"
destination = os.path.join(output_directory, local_filename)
Expand Down
2 changes: 1 addition & 1 deletion planemo/galaxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def config_join(*args):
tool_data_table_config_path=",".join(tool_data_tables) if tool_data_tables else None,
data_manager_config_file=",".join(data_manager_config_paths)
or None, # without 'or None' may raise IOError in galaxy (see #946)
integrated_tool_panel_config=("${temp_directory}/" "integrated_tool_panel_conf.xml"),
integrated_tool_panel_config=("${temp_directory}/integrated_tool_panel_conf.xml"),
migrated_tools_config=empty_tool_conf,
test_data_dir=test_data_dir, # TODO: make gx respect this
shed_data_manager_config_file=shed_data_manager_config_file,
Expand Down
2 changes: 0 additions & 2 deletions planemo/galaxy/distro_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@
"__DATA_FETCH__": "${model_tools_path}/data_fetch.xml",
"__IMPORT_HISTORY__": "${model_tools_path}/imp_exp/imp_history_from_archive.xml",
"__EXPORT_HISTORY__": "${model_tools_path}/imp_exp/exp_history_to_archive.xml",
"__UNZIP_COLLECTION__": "${model_tools_path}/unzip_collection.xml",
"__ZIP_COLLECTION__": "${model_tools_path}/zip_collection.xml",
"__FILTER_FAILED_DATASETS__": "${model_tools_path}/filter_failed_collection.xml",
"__FILTER_EMPTY_DATASETS__": "${model_tools_path}/filter_empty_collection.xml",
"__FLATTEN__": "${model_tools_path}/flatten_collection.xml",
"__SORTLIST__": "${model_tools_path}/sort_collection_list.xml",
"__MERGE_COLLECTION__": "${model_tools_path}/merge_collection.xml",
"__RELABEL_FROM_FILE__": "${model_tools_path}/relabel_from_file.xml",
"__FILTER_FROM_FILE__": "${model_tools_path}/filter_from_file.xml",
Expand Down
2 changes: 0 additions & 2 deletions planemo/galaxy/invocations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class Job(TypedDict, total=False):


class InvocationApi(Protocol):

def get_invocation(self, invocation_id: str) -> Invocation: ...

def get_invocation_summary(self, invocation_id: str, state: Optional[str] = None) -> InvocationJobsSummary: ...
Expand All @@ -56,7 +55,6 @@ def get_job(self, job_id: str, full_details: bool = False) -> Job: ...


class BioblendInvocationApi(InvocationApi):

def __init__(self, ctx, user_gi):
self._ctx = ctx
self._user_gi = user_gi
Expand Down
2 changes: 0 additions & 2 deletions planemo/galaxy/invocations/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@


class PollingTracker(Protocol):

def sleep(self) -> None: ...


class PollingTrackerImpl(PollingTracker):

def __init__(self, polling_backoff: int, timeout=None):
self.polling_backoff = polling_backoff
self.timeout = timeout
Expand Down
2 changes: 0 additions & 2 deletions planemo/galaxy/invocations/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class InvocationJobsSummary(TypedDict, total=False):


class WorkflowProgress(Progress):

_jobs_task: TaskID
_steps_task: TaskID
_subworkflows_task: Optional[TaskID] = None
Expand Down Expand Up @@ -339,7 +338,6 @@ def running_count(job_summary: InvocationJobsSummary) -> int:


class WorkflowProgressDisplay(Live):

def __init__(
self,
invocation_id: str,
Expand Down
2 changes: 0 additions & 2 deletions planemo/galaxy/invocations/simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def tick_when_active(self) -> None: ...


class StateWithDuration(Ticks):

def __init__(self, state: str, duration: int):
self.after = 0
self.state = state
Expand Down Expand Up @@ -98,7 +97,6 @@ def active_jobs(self) -> List[Job]:


class Invocation(HasState):

def __init__(self, steps: List[InvocationStep], after: int, states: List[StateWithDuration]):
self.id = str(uuid4())[:8]
self.steps = steps
Expand Down
2 changes: 1 addition & 1 deletion planemo/galaxy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
)


CACHED_VIRTUAL_ENV_COMMAND = "if [ -d .venv ]; " "then GALAXY_VIRTUAL_ENV=.venv; " "else GALAXY_VIRTUAL_ENV=%s; fi"
CACHED_VIRTUAL_ENV_COMMAND = "if [ -d .venv ]; then GALAXY_VIRTUAL_ENV=.venv; else GALAXY_VIRTUAL_ENV=%s; fi"
UNCACHED_VIRTUAL_ENV_COMMAND = "GALAXY_VIRTUAL_ENV=.venv"


Expand Down
10 changes: 5 additions & 5 deletions planemo/galaxy/test/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
from . import structures as test_structures

NO_XUNIT_REPORT_MESSAGE = (
"Cannot locate xUnit report [%s] for tests - " "required to build planemo report and summarize " "tests."
"Cannot locate xUnit report [%s] for tests - required to build planemo report and summarize tests."
)
NO_JSON_REPORT_MESSAGE = (
"Cannot locate JSON report [%s] for tests - " "required to build planemo report and summarize " "tests."
"Cannot locate JSON report [%s] for tests - required to build planemo report and summarize tests."
)
REPORT_NOT_CHANGED = (
"Galaxy failed to update test report [%s] for tests - " "required to build planemo report and summarize " "tests."
"Galaxy failed to update test report [%s] for tests - required to build planemo report and summarize tests."
)
NO_TESTS_MESSAGE = "No tests were executed - see Galaxy output for details."
ALL_TESTS_PASSED_MESSAGE = "All %d test(s) executed passed."
PROBLEM_COUNT_MESSAGE = (
"There were problems with %d test(s) - out of %d " "test(s) executed. See %s for detailed breakdown."
"There were problems with %d test(s) - out of %d test(s) executed. See %s for detailed breakdown."
)
GENERIC_PROBLEMS_MESSAGE = "One or more tests failed. See %s for detailed " "breakdown."
GENERIC_PROBLEMS_MESSAGE = "One or more tests failed. See %s for detailed breakdown."
GENERIC_TESTS_PASSED_MESSAGE = "No failing tests encountered."
TEST_DATA_UPDATED_MESSAGE = "Test data were updated and tests were rerun."
TEST_DATA_NOT_UPDATED_MESSAGE = "%s Therefore, no test data were updated." % ALL_TESTS_PASSED_MESSAGE
Expand Down
2 changes: 1 addition & 1 deletion planemo/github_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

GH_VERSION = "1.5.0"

NO_GITHUB_DEP_ERROR = "Cannot use github functionality - " "PyGithub library not available."
NO_GITHUB_DEP_ERROR = "Cannot use github functionality - PyGithub library not available."
FAILED_TO_DOWNLOAD_GH = "No gh executable available and it could not be installed."
DEFAULT_REMOTE_NAME = "planemo-remote"
SLEEP_BEFORE_RELEASE = int(os.environ.get("PLANEMO_SLEEP_BEFORE_RELEASE", 60))
Expand Down
Loading