From 642fd89b1d047125fa6b7e4dfd7a331b0620257d Mon Sep 17 00:00:00 2001 From: Daniel Neilson <53624638+ddneilson@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:39:01 +0000 Subject: [PATCH] chore: reformat for updated black version Signed-off-by: Daniel Neilson <53624638+ddneilson@users.noreply.github.com> --- pyproject.toml | 9 +++--- src/openjd/cli/_summary/_summary_output.py | 6 ++-- test/openjd/cli/test_local_session.py | 33 ++++++++++++++-------- test/openjd/cli/test_run_command.py | 13 +++++---- test/openjd/cli/test_schema_command.py | 5 ++-- test/openjd/cli/test_summary_command.py | 7 +++-- 6 files changed, 44 insertions(+), 29 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d887df8..4f49af5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,15 +106,16 @@ mypy_path = "src" plugins = "pydantic.mypy" [tool.ruff] +line-length = 100 + +[tool.ruff.lint] ignore = [ "E501", # Double Check if this should be fixed "E731", ] -line-length = 100 - -[tool.ruff.pep8-naming] +[tool.ruff.lint.pep8-naming] classmethod-decorators = [ "classmethod", # pydantic decorators are classmethod decorators @@ -123,7 +124,7 @@ classmethod-decorators = [ "pydantic.root_validator", ] -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = [ "openjd", ] diff --git a/src/openjd/cli/_summary/_summary_output.py b/src/openjd/cli/_summary/_summary_output.py index 82631e2..125f3f1 100644 --- a/src/openjd/cli/_summary/_summary_output.py +++ b/src/openjd/cli/_summary/_summary_output.py @@ -289,9 +289,9 @@ def output_summary_result(job: Job, step_name: str | None = None) -> OpenJDCliRe message=f"Summary for Step '{step.name}' in Job '{job.name}'", job_name=job.name, step_name=step.name, - total_parameters=len(step.parameter_definitions) - if step.parameter_definitions - else 0, + total_parameters=( + len(step.parameter_definitions) if step.parameter_definitions else 0 + ), parameter_definitions=step.parameter_definitions, total_tasks=step.total_tasks, total_environments=len(step.environments) if step.environments else 0, diff --git a/test/openjd/cli/test_local_session.py b/test/openjd/cli/test_local_session.py index 907dc35..81df9aa 100644 --- a/test/openjd/cli/test_local_session.py +++ b/test/openjd/cli/test_local_session.py @@ -23,15 +23,23 @@ def patched_actions(): hang when mocking actions directly, so we just run the Session to completion with short sample Jobs) """ - with patch.object( - Session, "enter_environment", autospec=True, side_effect=Session.enter_environment - ) as patched_enter, patch.object( - Session, "run_task", autospec=True, side_effect=Session.run_task - ) as patched_run, patch.object( - Session, "exit_environment", autospec=True, side_effect=Session.exit_environment - ) as patched_exit, patch.object( - LocalSession, "_action_callback", autospec=True, side_effect=LocalSession._action_callback - ) as patched_callback: + with ( + patch.object( + Session, "enter_environment", autospec=True, side_effect=Session.enter_environment + ) as patched_enter, + patch.object( + Session, "run_task", autospec=True, side_effect=Session.run_task + ) as patched_run, + patch.object( + Session, "exit_environment", autospec=True, side_effect=Session.exit_environment + ) as patched_exit, + patch.object( + LocalSession, + "_action_callback", + autospec=True, + side_effect=LocalSession._action_callback, + ) as patched_callback, + ): yield patched_enter, patched_run, patched_exit, patched_callback @@ -192,9 +200,10 @@ def test_localsession_run_not_ready(sample_job_and_dirs: tuple): """ sample_job, template_dir, current_working_dir = sample_job_and_dirs with LocalSession(job=sample_job, session_id="my-session") as session: - with patch.object(Session, "state", new=SessionState.ENDED), pytest.raises( - RuntimeError - ) as rte: + with ( + patch.object(Session, "state", new=SessionState.ENDED), + pytest.raises(RuntimeError) as rte, + ): session.run() assert "not in a READY state" in str(rte.value) diff --git a/test/openjd/cli/test_run_command.py b/test/openjd/cli/test_run_command.py index f145244..12ba1d9 100644 --- a/test/openjd/cli/test_run_command.py +++ b/test/openjd/cli/test_run_command.py @@ -479,11 +479,14 @@ def test_run_local_session_success( destination_path=PurePosixPath("/mnt/test"), ) ] - with patch.object( - LocalSession, "initialize", autospec=True, side_effect=LocalSession.initialize - ) as patched_initialize, patch.object( - Session, "__init__", autospec=True, side_effect=Session.__init__ - ) as patched_session_init: + with ( + patch.object( + LocalSession, "initialize", autospec=True, side_effect=LocalSession.initialize + ) as patched_initialize, + patch.object( + Session, "__init__", autospec=True, side_effect=Session.__init__ + ) as patched_session_init, + ): response = _run_local_session( job=sample_job, step_map=sample_step_map, diff --git a/test/openjd/cli/test_schema_command.py b/test/openjd/cli/test_schema_command.py index e722877..e8bb641 100644 --- a/test/openjd/cli/test_schema_command.py +++ b/test/openjd/cli/test_schema_command.py @@ -120,8 +120,9 @@ def test_do_get_schema_error(capsys: pytest.CaptureFixture): when generating the JSON schema. """ - with patch.object(BaseModel, "schema", side_effect=RuntimeError("Test error")), pytest.raises( - SystemExit + with ( + patch.object(BaseModel, "schema", side_effect=RuntimeError("Test error")), + pytest.raises(SystemExit), ): do_get_schema(Namespace(version=SchemaVersion.v2023_09, output="human-readable")) output = capsys.readouterr().out diff --git a/test/openjd/cli/test_summary_command.py b/test/openjd/cli/test_summary_command.py index 40cf963..a3e2bd2 100644 --- a/test/openjd/cli/test_summary_command.py +++ b/test/openjd/cli/test_summary_command.py @@ -75,9 +75,10 @@ def test_do_summary_error(): Test that the `summary` command exits on any error (in this case, we mock an error in `read_template`) """ mock_args = Namespace(path=Path("some-file.json"), output="human-readable") - with patch( - "openjd.cli._common.read_template", new=Mock(side_effect=RuntimeError()) - ), pytest.raises(SystemExit): + with ( + patch("openjd.cli._common.read_template", new=Mock(side_effect=RuntimeError())), + pytest.raises(SystemExit), + ): do_summary(mock_args)