From da01dc816455c8b407de39f17d6f5a08376b4c25 Mon Sep 17 00:00:00 2001 From: Zoheb Shaikh Date: Thu, 16 Jan 2025 11:01:54 +0000 Subject: [PATCH] Fix ruff lint --- src/blueapi/cli/format.py | 6 +++--- src/blueapi/cli/scratch.py | 3 +-- tests/unit_tests/test_cli.py | 8 ++++---- tests/unit_tests/test_config.py | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/blueapi/cli/format.py b/src/blueapi/cli/format.py index 8d8ac744a..de89ee7f9 100644 --- a/src/blueapi/cli/format.py +++ b/src/blueapi/cli/format.py @@ -25,7 +25,7 @@ def fmt_dict(t: dict[str, Any] | Any, ind: int = 1) -> str: if not isinstance(t, dict): return f" {t}" pre = " " * (ind * 4) - return NL + NL.join(f"{pre}{k}:{fmt_dict(v, ind+1)}" for k, v in t.items() if v) + return NL + NL.join(f"{pre}{k}:{fmt_dict(v, ind + 1)}" for k, v in t.items() if v) class OutputFormat(str, enum.Enum): @@ -126,14 +126,14 @@ def _describe_type(spec: dict[Any, Any], required: bool = False): case None: if all_of := spec.get("allOf"): items = (_describe_type(f, False) for f in all_of) - disp += f'{" & ".join(items)}' + disp += f"{' & '.join(items)}" elif any_of := spec.get("anyOf"): items = (_describe_type(f, False) for f in any_of) # Special case: Where the type is | null, # we should just print items = (item for item in items if item != "null" or len(any_of) != 2) - disp += f'{" | ".join(items)}' + disp += f"{' | '.join(items)}" else: disp += "Any" case "array": diff --git a/src/blueapi/cli/scratch.py b/src/blueapi/cli/scratch.py index e2161799b..86e4d19a9 100644 --- a/src/blueapi/cli/scratch.py +++ b/src/blueapi/cli/scratch.py @@ -57,8 +57,7 @@ def ensure_repo(remote_url: str, local_directory: Path) -> None: logging.info(f"Found {local_directory}") else: raise KeyError( - f"Unable to open {local_directory} as a git repository because " - "it is a file" + f"Unable to open {local_directory} as a git repository because it is a file" ) diff --git a/tests/unit_tests/test_cli.py b/tests/unit_tests/test_cli.py index fb918fb66..55f066470 100644 --- a/tests/unit_tests/test_cli.py +++ b/tests/unit_tests/test_cli.py @@ -310,7 +310,7 @@ def test_env_timeout(mock_sleep: Mock, runner: CliRunner): assert responses.calls[0].request.url == "http://localhost:8000/environment" # Remaining calls should all be GET - for call in responses.calls[1:]: # Skip the first DELETE request + for call in responses.calls[1:]: # Skip the first DELETE request # type: ignore assert call.request.method == "GET" assert call.request.url == "http://localhost:8000/environment" @@ -329,9 +329,9 @@ def test_env_reload_server_side_error(runner: CliRunner): ) result = runner.invoke(main, ["controller", "env", "-r"]) - assert isinstance( - result.exception, BlueskyRemoteControlError - ), "Expected a BlueskyRemoteError from cli runner" + assert isinstance(result.exception, BlueskyRemoteControlError), ( + "Expected a BlueskyRemoteError from cli runner" + ) assert result.exception.args[0] == "Failed to tear down the environment" # Check if the endpoints were hit as expected diff --git a/tests/unit_tests/test_config.py b/tests/unit_tests/test_config.py index 67517a691..ee918bc9c 100644 --- a/tests/unit_tests/test_config.py +++ b/tests/unit_tests/test_config.py @@ -343,9 +343,9 @@ def test_config_yaml_parsed_complete(temp_yaml_config_file: dict): del target_dict_json["stomp"]["auth"]["password"] del config_data["stomp"]["auth"]["password"] # noqa: E501 # Assert that the remaining config data is identical - assert ( - target_dict_json == config_data - ), f"Expected config {config_data}, but got {target_dict_json}" + assert target_dict_json == config_data, ( + f"Expected config {config_data}, but got {target_dict_json}" + ) def test_oauth_config_model_post_init(