fix(lint): remove duplicate ImportError clauses and reformat files
Remove duplicate except ImportError blocks in cloud_resources_steps.py (B025 violations in step_sandbox_create, step_sandbox_commit, step_sandbox_rollback). Apply ruff format to 5 files flagged by the format check.
This commit is contained in:
@@ -180,7 +180,7 @@ def step_discovery_item_key(context: Any, key: str) -> None:
|
||||
"""Check that each discovery item has the expected key."""
|
||||
result = context.discovery_result # type: ignore[attr-defined]
|
||||
for item in result:
|
||||
assert key in item, f"Key \'{key}\' not found in item: {item}"
|
||||
assert key in item, f"Key '{key}' not found in item: {item}"
|
||||
|
||||
|
||||
@then('awssdk each discovery item arn should start with "{prefix}"')
|
||||
@@ -190,7 +190,7 @@ def step_discovery_item_arn_prefix(context: Any, prefix: str) -> None:
|
||||
for item in result:
|
||||
arn = item.get("arn", "")
|
||||
assert arn.startswith(prefix), (
|
||||
f"Expected ARN to start with \'{prefix}\', got \'{arn}\'"
|
||||
f"Expected ARN to start with '{prefix}', got '{arn}'"
|
||||
)
|
||||
|
||||
|
||||
@@ -216,6 +216,6 @@ def step_result_count(context: Any, count: int) -> None:
|
||||
def step_aws_resource_map_contains(context: Any, type_name: str) -> None:
|
||||
"""Check that the AWS resource map contains the expected type."""
|
||||
assert type_name in _AWS_RESOURCE_MAP, (
|
||||
f"\'{type_name}\' not found in _AWS_RESOURCE_MAP. "
|
||||
f"'{type_name}' not found in _AWS_RESOURCE_MAP. "
|
||||
f"Available: {sorted(_AWS_RESOURCE_MAP.keys())}"
|
||||
)
|
||||
|
||||
@@ -249,7 +249,7 @@ def step_import_error_raised(context: Any, text: str) -> None:
|
||||
f"{context.raised_error}" # type: ignore[attr-defined]
|
||||
)
|
||||
msg = str(context.raised_error) # type: ignore[attr-defined]
|
||||
assert text in msg, f"\'{text}\' not found in ImportError: {msg}"
|
||||
assert text in msg, f"'{text}' not found in ImportError: {msg}"
|
||||
|
||||
|
||||
@then("awssdk the session should be created successfully")
|
||||
@@ -267,7 +267,7 @@ def step_session_created_with_profile(context: Any, profile: str) -> None:
|
||||
mock_boto3: MagicMock = context.mock_boto3 # type: ignore[attr-defined]
|
||||
call_kwargs = mock_boto3.Session.call_args[1]
|
||||
assert call_kwargs.get("profile_name") == profile, (
|
||||
f"Expected profile_name=\'{profile}\', got {call_kwargs}"
|
||||
f"Expected profile_name='{profile}', got {call_kwargs}"
|
||||
)
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ def step_bound_resource_slot(context: Any, slot_name: str) -> None:
|
||||
|
||||
br: BoundResource = context.bound_resource # type: ignore[attr-defined]
|
||||
assert br.slot_name == slot_name, (
|
||||
f"Expected slot_name=\'{slot_name}\', got \'{br.slot_name}\'"
|
||||
f"Expected slot_name='{slot_name}', got '{br.slot_name}'"
|
||||
)
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ def step_bound_resource_type(context: Any, resource_type: str) -> None:
|
||||
|
||||
br: BoundResource = context.bound_resource # type: ignore[attr-defined]
|
||||
assert br.resource_type == resource_type, (
|
||||
f"Expected resource_type=\'{resource_type}\', got \'{br.resource_type}\'"
|
||||
f"Expected resource_type='{resource_type}', got '{br.resource_type}'"
|
||||
)
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ def step_bound_resource_sandbox_path(context: Any, text: str) -> None:
|
||||
br: BoundResource = context.bound_resource # type: ignore[attr-defined]
|
||||
assert br.sandbox_path is not None, "Expected sandbox_path to be set"
|
||||
assert text in br.sandbox_path, (
|
||||
f"Expected \'{text}\' in sandbox_path=\'{br.sandbox_path}\'"
|
||||
f"Expected '{text}' in sandbox_path='{br.sandbox_path}'"
|
||||
)
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ def step_value_error_raised(context: Any, text: str) -> None:
|
||||
f"{context.raised_error}" # type: ignore[attr-defined]
|
||||
)
|
||||
msg = str(context.raised_error) # type: ignore[attr-defined]
|
||||
assert text in msg, f"\'{text}\' not found in ValueError: {msg}"
|
||||
assert text in msg, f"'{text}' not found in ValueError: {msg}"
|
||||
|
||||
|
||||
@then('awssdk a NotImplementedError should be raised mentioning "{text}"')
|
||||
@@ -338,7 +338,7 @@ def step_not_implemented_raised(context: Any, text: str) -> None:
|
||||
f"{context.raised_error}" # type: ignore[attr-defined]
|
||||
)
|
||||
msg = str(context.raised_error) # type: ignore[attr-defined]
|
||||
assert text in msg, f"\'{text}\' not found in NotImplementedError: {msg}"
|
||||
assert text in msg, f"'{text}' not found in NotImplementedError: {msg}"
|
||||
|
||||
|
||||
@then("awssdk a NotImplementedError should be raised")
|
||||
|
||||
@@ -276,12 +276,6 @@ def step_sandbox_create(context: Any) -> None:
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@when("I call commit on the sandbox strategy")
|
||||
@@ -298,12 +292,6 @@ def step_sandbox_commit(context: Any) -> None:
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@when("I call rollback on the sandbox strategy")
|
||||
@@ -320,12 +308,6 @@ def step_sandbox_rollback(context: Any) -> None:
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
except ImportError as exc:
|
||||
context.handler_error = exc # type: ignore[attr-defined]
|
||||
context.handler_error_type = "ImportError" # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@when("I validate the cloud sandbox strategy")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Minimal type stub for boto3."""
|
||||
from typing import Any
|
||||
|
||||
from typing import Any
|
||||
|
||||
class Session:
|
||||
def __init__(
|
||||
@@ -12,6 +12,5 @@ class Session:
|
||||
profile_name: str | None = None,
|
||||
**kwargs: Any,
|
||||
) -> None: ...
|
||||
|
||||
def client(self, service_name: str, **kwargs: Any) -> Any: ...
|
||||
def resource(self, service_name: str, **kwargs: Any) -> Any: ...
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""Minimal type stub for botocore.exceptions."""
|
||||
|
||||
|
||||
class BotoCoreError(Exception): ...
|
||||
|
||||
|
||||
class ClientError(BotoCoreError):
|
||||
response: dict[str, object]
|
||||
operation_name: str
|
||||
|
||||
def __init__(self, error_response: dict[str, object], operation_name: str) -> None: ...
|
||||
def __init__(
|
||||
self, error_response: dict[str, object], operation_name: str
|
||||
) -> None: ...
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""Minimal type stub for botocore.exceptions."""
|
||||
|
||||
|
||||
class BotoCoreError(Exception): ...
|
||||
|
||||
|
||||
class ClientError(BotoCoreError):
|
||||
response: dict[str, object]
|
||||
operation_name: str
|
||||
|
||||
def __init__(self, error_response: dict[str, object], operation_name: str) -> None: ...
|
||||
def __init__(
|
||||
self, error_response: dict[str, object], operation_name: str
|
||||
) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user