Skip to content

Commit f9039a4

Browse files
style: auto-format code with ruff
1 parent ebf8c6d commit f9039a4

5 files changed

Lines changed: 43 additions & 22 deletions

File tree

dev-tools/setup/install_dev_tools.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,7 @@ def _install_bun_generic(self):
413413
def _install_actionlint_generic(self):
414414
"""Install actionlint using official download script (curl-to-tempfile, no shell=True)."""
415415
if self.dry_run:
416-
logger.info(
417-
"[DRY RUN] Would download actionlint install script and run: bash <script>"
418-
)
416+
logger.info("[DRY RUN] Would download actionlint install script and run: bash <script>")
419417
return True
420418
with tempfile.NamedTemporaryFile(suffix=".bash", delete=False) as tmp:
421419
tmp_path = tmp.name
@@ -438,7 +436,9 @@ def _install_shellcheck_generic(self):
438436

439437
url = f"https://github.com/koalaman/shellcheck/releases/latest/download/shellcheck-latest.linux.{arch}.tar.xz"
440438
if self.dry_run:
441-
logger.info(f"[DRY RUN] Would download shellcheck from {url} and extract to /usr/local/bin")
439+
logger.info(
440+
f"[DRY RUN] Would download shellcheck from {url} and extract to /usr/local/bin"
441+
)
442442
return True
443443
with tempfile.NamedTemporaryFile(suffix=".tar.xz", delete=False) as tmp:
444444
tmp_path = tmp.name
@@ -466,7 +466,9 @@ def _install_trufflehog_generic(self):
466466

467467
url = f"https://github.com/trufflesecurity/trufflehog/releases/latest/download/trufflehog_linux_{arch}.tar.gz"
468468
if self.dry_run:
469-
logger.info(f"[DRY RUN] Would download trufflehog from {url} and extract to /usr/local/bin")
469+
logger.info(
470+
f"[DRY RUN] Would download trufflehog from {url} and extract to /usr/local/bin"
471+
)
470472
return True
471473
with tempfile.NamedTemporaryFile(suffix=".tar.gz", delete=False) as tmp:
472474
tmp_path = tmp.name
@@ -482,7 +484,13 @@ def _install_act_generic(self):
482484
with tempfile.NamedTemporaryFile(suffix=".sh", delete=False) as tmp:
483485
tmp_path = tmp.name
484486
return self._run_command(
485-
["curl", "-s", "-o", tmp_path, "https://raw.githubusercontent.com/nektos/act/master/install.sh"]
487+
[
488+
"curl",
489+
"-s",
490+
"-o",
491+
tmp_path,
492+
"https://raw.githubusercontent.com/nektos/act/master/install.sh",
493+
]
486494
) and self._run_command(["sudo", "bash", tmp_path])
487495

488496
def _install_pip_audit_python(self):

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,7 @@ async def revoke_token(self, token: str) -> bool:
291291
return True
292292
except ClientError as exc:
293293
error_code = exc.response.get("Error", {}).get("Code", "Unknown")
294-
self._logger.error(
295-
"Cognito RevokeToken API call failed (code=%s)", error_code
296-
)
294+
self._logger.error("Cognito RevokeToken API call failed (code=%s)", error_code)
297295
return False
298296
else:
299297
# Access tokens (token_use == "access") or unrecognised/malformed tokens:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def _mask_config_dict(config: dict) -> dict:
2121
masked[k] = v
2222
return masked
2323

24+
2425
from botocore.config import Config
2526
from botocore.exceptions import ClientError
2627

tests/infrastructure/error/test_http_response_handler.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def handler(self):
4444

4545
def test_validation_error_http(self, handler):
4646
"""Test validation error HTTP response returns safe message, keeps field-level details."""
47-
exception = ValidationError("Internal field path: user.secret_token", details={"field": "name"})
47+
exception = ValidationError(
48+
"Internal field path: user.secret_token", details={"field": "name"}
49+
)
4850

4951
response = handler.handle_error_for_http(exception)
5052

@@ -96,7 +98,9 @@ def test_request_not_found_http(self, handler):
9698

9799
def test_request_validation_http(self, handler):
98100
"""Test request validation error HTTP response returns safe message, keeps field details."""
99-
exception = RequestValidationError("Invalid request: count must be <= 500", details={"field": "count"})
101+
exception = RequestValidationError(
102+
"Invalid request: count must be <= 500", details={"field": "count"}
103+
)
100104

101105
response = handler.handle_error_for_http(exception)
102106

@@ -121,7 +125,9 @@ def test_machine_not_found_http(self, handler):
121125

122126
def test_machine_validation_http(self, handler):
123127
"""Test machine validation error HTTP response returns safe message, keeps field details."""
124-
exception = MachineValidationError("Invalid machine: internal type code 0x3F", details={"field": "type"})
128+
exception = MachineValidationError(
129+
"Invalid machine: internal type code 0x3F", details={"field": "type"}
130+
)
125131

126132
response = handler.handle_error_for_http(exception)
127133

@@ -147,7 +153,8 @@ def test_template_not_found_http(self, handler):
147153
def test_template_validation_http(self, handler):
148154
"""Test template validation error HTTP response returns safe message, keeps field details."""
149155
exception = TemplateValidationError(
150-
"Invalid template: internal path /etc/templates/secret.yaml", details={"field": "config"}
156+
"Invalid template: internal path /etc/templates/secret.yaml",
157+
details={"field": "config"},
151158
)
152159

153160
response = handler.handle_error_for_http(exception)
@@ -161,7 +168,9 @@ def test_template_validation_http(self, handler):
161168

162169
def test_infrastructure_error_http(self, handler):
163170
"""Test infrastructure error HTTP response does not leak original_error to client."""
164-
exception = InfrastructureError("Database connection failed: host=internal-db.corp port=5432")
171+
exception = InfrastructureError(
172+
"Database connection failed: host=internal-db.corp port=5432"
173+
)
165174

166175
response = handler.handle_error_for_http(exception)
167176

@@ -174,7 +183,9 @@ def test_infrastructure_error_http(self, handler):
174183

175184
def test_configuration_error_http(self, handler):
176185
"""Test configuration error HTTP response does not leak original_error to client."""
177-
exception = ConfigurationError("Invalid config: secret_key=abc123 at path /etc/orb/config.yaml")
186+
exception = ConfigurationError(
187+
"Invalid config: secret_key=abc123 at path /etc/orb/config.yaml"
188+
)
178189

179190
response = handler.handle_error_for_http(exception)
180191

@@ -255,7 +266,9 @@ def test_infrastructure_error_does_not_leak_secret_to_client_but_logs_it(self, h
255266
original_logger = handler._logger
256267

257268
mock_logger = MagicMock()
258-
mock_logger.error.side_effect = lambda *args, **kwargs: log_calls.append(("error", args, kwargs))
269+
mock_logger.error.side_effect = lambda *args, **kwargs: log_calls.append(
270+
("error", args, kwargs)
271+
)
259272
handler._logger = mock_logger
260273

261274
try:
@@ -275,9 +288,7 @@ def test_infrastructure_error_does_not_leak_secret_to_client_but_logs_it(self, h
275288

276289
def test_duplicate_error_does_not_leak_raw_message(self, handler):
277290
"""DuplicateError returns a generic safe message; raw detail stays out of response."""
278-
exception = DuplicateError(
279-
"Duplicate key: machine_id=m-secret-prod-123 in table machines"
280-
)
291+
exception = DuplicateError("Duplicate key: machine_id=m-secret-prod-123 in table machines")
281292

282293
response = handler.handle_error_for_http(exception)
283294

tests/providers/aws/unit/test_iam_strategy.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ def _make_simulate_response(*entries: tuple[str, str]) -> dict:
129129
"""
130130
return {
131131
"EvaluationResults": [
132-
{"EvalActionName": action, "EvalDecision": decision}
133-
for action, decision in entries
132+
{"EvalActionName": action, "EvalDecision": decision} for action, decision in entries
134133
]
135134
}
136135

@@ -196,7 +195,11 @@ async def test_iam_check_permissions_mixed_decisions():
196195
"""_check_permissions returns only the allowed subset from a mixed response."""
197196
strategy = _make_strategy(assume_permissions=False)
198197
strategy._assume_permissions = False
199-
strategy.required_actions = ["ec2:DescribeInstances", "ec2:RunInstances", "ec2:TerminateInstances"]
198+
strategy.required_actions = [
199+
"ec2:DescribeInstances",
200+
"ec2:RunInstances",
201+
"ec2:TerminateInstances",
202+
]
200203

201204
strategy.iam_client.simulate_principal_policy.return_value = _make_simulate_response(
202205
("ec2:DescribeInstances", "allowed"),

0 commit comments

Comments
 (0)