Skip to content

Commit

Permalink
Fix ruff lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ZohebShaikh committed Jan 16, 2025
1 parent efcb4aa commit da01dc8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/blueapi/cli/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 <something> | null,
# we should just print <something>
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":
Expand Down
3 changes: 1 addition & 2 deletions src/blueapi/cli/scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)


Expand Down
8 changes: 4 additions & 4 deletions tests/unit_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit da01dc8

Please sign in to comment.