Skip to content
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

Fix ruff lint #786

Merged
merged 3 commits into from
Jan 17, 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
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ rich-toolkit==0.12.0
rpds-py==0.22.3
ruamel.yaml==0.18.6
ruamel.yaml.clib==0.2.12
ruff==0.8.2
ruff==0.9.1
scanspec==0.7.6
semver==3.0.2
setuptools-dso==2.11
Expand Down
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 @@ -311,7 +311,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 @@ -330,9 +330,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
Loading