Skip to content

Commit 766514e

Browse files
style: auto-format code with ruff
1 parent 7feac6d commit 766514e

13 files changed

Lines changed: 48 additions & 50 deletions

File tree

dev-tools/setup/install_dev_tools.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,7 @@ def _install_actionlint_generic(self):
534534
a checksum-verified alternative is available.
535535
"""
536536
if self.dry_run:
537-
logger.info(
538-
"[DRY RUN] Would download actionlint install script and run: bash <script>"
539-
)
537+
logger.info("[DRY RUN] Would download actionlint install script and run: bash <script>")
540538
return True
541539
fd, tmp_path = tempfile.mkstemp(suffix=".bash")
542540
try:
@@ -573,7 +571,9 @@ def _install_shellcheck_generic(self):
573571

574572
url = f"https://github.com/koalaman/shellcheck/releases/latest/download/shellcheck-latest.linux.{arch}.tar.xz"
575573
if self.dry_run:
576-
logger.info(f"[DRY RUN] Would download shellcheck from {url} and extract to /usr/local/bin")
574+
logger.info(
575+
f"[DRY RUN] Would download shellcheck from {url} and extract to /usr/local/bin"
576+
)
577577
return True
578578
fd, tmp_path = tempfile.mkstemp(suffix=".tar.xz")
579579
try:
@@ -616,14 +616,14 @@ def _install_trufflehog_generic(self):
616616

617617
url = f"https://github.com/trufflesecurity/trufflehog/releases/latest/download/trufflehog_linux_{arch}.tar.gz"
618618
if self.dry_run:
619-
logger.info(f"[DRY RUN] Would download trufflehog from {url} and extract to /usr/local/bin")
619+
logger.info(
620+
f"[DRY RUN] Would download trufflehog from {url} and extract to /usr/local/bin"
621+
)
620622
return True
621623
fd, tmp_path = tempfile.mkstemp(suffix=".tar.gz")
622624
try:
623625
os.close(fd)
624-
ok = self._run_command(
625-
["curl", "-L", "-o", tmp_path, url]
626-
) and self._run_command(
626+
ok = self._run_command(["curl", "-L", "-o", tmp_path, url]) and self._run_command(
627627
["sudo", "tar", "-xz", "-C", "/usr/local/bin", "-f", tmp_path, "trufflehog"]
628628
)
629629
finally:

src/orb/api/routers/machines.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,10 @@ async def purge_machine(
315315
logger.warning("Machine purge failed — not found: %s", exc)
316316
return JSONResponse(
317317
status_code=404,
318-
content={"success": False, "error": {"code": "NOT_FOUND", "message": "Machine not found."}},
318+
content={
319+
"success": False,
320+
"error": {"code": "NOT_FOUND", "message": "Machine not found."},
321+
},
319322
)
320323
except NonTerminalStatusError as exc:
321324
logger.warning("Machine purge rejected — non-terminal status: %s", exc)

src/orb/api/routers/requests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ async def purge_request(
324324
_logger.warning("Request purge failed — not found: %s", exc)
325325
return JSONResponse(
326326
status_code=404,
327-
content={"success": False, "error": {"code": "NOT_FOUND", "message": "Request not found."}},
327+
content={
328+
"success": False,
329+
"error": {"code": "NOT_FOUND", "message": "Request not found."},
330+
},
328331
)
329332
except NonTerminalStatusError as exc:
330333
_logger.warning("Request purge rejected — non-terminal status: %s", exc)

src/orb/providers/aws/auth/iam_strategy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,7 @@ async def _get_caller_identity(self) -> Optional[dict[str, Any]]:
295295
Caller identity information
296296
"""
297297
try:
298-
response: dict[str, Any] = await asyncio.to_thread(
299-
self.sts_client.get_caller_identity
300-
)
298+
response: dict[str, Any] = await asyncio.to_thread(self.sts_client.get_caller_identity)
301299
return response
302300
except Exception as e:
303301
self._logger.error("Failed to get caller identity: %s", e)

src/orb/providers/aws/infrastructure/aws_client.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
# Exact-match keys whose values are always sensitive, regardless of surrounding
77
# characters. Also used as suffix patterns ("ends with").
8-
_SECRET_EXACT_KEYS = frozenset(
9-
{"access_key_id", "secret_access_key", "session_token"}
10-
)
8+
_SECRET_EXACT_KEYS = frozenset({"access_key_id", "secret_access_key", "session_token"})
119

1210
# Substring fragments that indicate a sensitive key when found anywhere in the
1311
# lowercased field name. Deliberately excludes bare "key" to avoid hiding
@@ -50,10 +48,7 @@ def _mask_config_dict(config: dict) -> dict:
5048
# even when the parent key itself is not sensitive.
5149
masked[k] = _mask_config_dict(v)
5250
elif isinstance(v, list):
53-
masked[k] = [
54-
_mask_config_dict(item) if isinstance(item, dict) else item
55-
for item in v
56-
]
51+
masked[k] = [_mask_config_dict(item) if isinstance(item, dict) else item for item in v]
5752
elif _is_sensitive_key(k):
5853
masked[k] = "***"
5954
else:

tests/infrastructure/error/test_http_response_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ def test_duplicate_error_does_not_leak_raw_message(self, handler):
295295
assert response.message == "A duplicate resource already exists"
296296
assert "m-secret-prod-123" not in response.message
297297
assert "m-secret-prod-123" not in str(response.details)
298+
298299
# --- Regression tests ---
299300

300301
def test_not_found_message_does_not_contain_entity_id(self, handler):
@@ -374,4 +375,3 @@ def test_unexpected_error_is_logged(self, handler):
374375

375376
# Server-side log must have been called
376377
assert len(logged) >= 1, "Expected at least one logger.error call for unexpected errors"
377-

tests/infrastructure/error/test_responses.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ def test_configuration_error_details_are_empty(self):
8181
"""Regression (H3): ConfigurationError details must be empty on the response."""
8282
exception = ConfigurationError(
8383
"bad config",
84-
details={"original_error": "key=db_password value=s3cr3t", "filename": "/etc/orb/config.yaml"},
84+
details={
85+
"original_error": "key=db_password value=s3cr3t",
86+
"filename": "/etc/orb/config.yaml",
87+
},
8588
)
8689

8790
response = InfrastructureErrorResponse.from_exception(exception)

tests/providers/aws/unit/test_cognito_strategy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ def _make_fake_jwt_token(token_use: str = "access", exp_offset: int = 3600) -> s
8080
"iss": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_EXAMPLE",
8181
"aud": "abc123",
8282
}
83-
payload = (
84-
base64.urlsafe_b64encode(json.dumps(payload_data).encode()).rstrip(b"=").decode()
85-
)
83+
payload = base64.urlsafe_b64encode(json.dumps(payload_data).encode()).rstrip(b"=").decode()
8684
sig = "fakesignatureAABBCC"
8785
return f"{header}.{payload}.{sig}"
8886

tests/unit/api/test_admin_router.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,9 @@ class TestReloadConfigNoInfoLeak:
740740
"""Broad Exception during config reload must not expose internal text in the
741741
500 response body, but must be visible in the server ERROR log."""
742742

743-
def _make_failing_container(self, config_port, machine_repo, request_repo, template_repo, secret):
743+
def _make_failing_container(
744+
self, config_port, machine_repo, request_repo, template_repo, secret
745+
):
744746
"""Return a DI container whose ConfigurationManager.reload() raises with *secret*."""
745747
from orb.domain.base import UnitOfWorkFactory
746748
from orb.domain.base.ports.configuration_port import ConfigurationPort

tests/unit/api/test_config_router.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,10 @@ def _make_save_app(self):
387387

388388
# Satisfy the destructive-admin guard embedded in save_config.
389389
config_port_for_guard = MagicMock()
390-
config_port_for_guard.get_configuration_value.side_effect = (
391-
lambda key, default=None: {
392-
"allow_destructive_admin": True,
393-
"environment": "development",
394-
}.get(key, default)
395-
)
390+
config_port_for_guard.get_configuration_value.side_effect = lambda key, default=None: {
391+
"allow_destructive_admin": True,
392+
"environment": "development",
393+
}.get(key, default)
396394
server_config = MagicMock()
397395
server_config.auth.enabled = True
398396

@@ -427,9 +425,10 @@ def test_value_error_text_not_in_response_body(self, config_app, caplog):
427425
server_config = MagicMock()
428426
server_config.auth.enabled = True
429427

430-
with patch("orb.api.dependencies.get_di_container", return_value=MagicMock(
431-
**{"get.return_value": port}
432-
)):
428+
with patch(
429+
"orb.api.dependencies.get_di_container",
430+
return_value=MagicMock(**{"get.return_value": port}),
431+
):
433432
with patch("orb.api.dependencies.get_server_config", return_value=server_config):
434433
with caplog.at_level(logging.WARNING, logger="orb.api.routers.config"):
435434
client = TestClient(config_app, raise_server_exceptions=False)
@@ -470,9 +469,10 @@ def test_no_config_path_error_code_unchanged(self, config_app):
470469
server_config = MagicMock()
471470
server_config.auth.enabled = True
472471

473-
with patch("orb.api.dependencies.get_di_container", return_value=MagicMock(
474-
**{"get.return_value": port}
475-
)):
472+
with patch(
473+
"orb.api.dependencies.get_di_container",
474+
return_value=MagicMock(**{"get.return_value": port}),
475+
):
476476
with patch("orb.api.dependencies.get_server_config", return_value=server_config):
477477
client = TestClient(config_app, raise_server_exceptions=False)
478478
r = client.post("/config/save", json={})

0 commit comments

Comments
 (0)