From 31c8bae2c6dcbfef278ae1c75dfdced5f41dc7f3 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Fri, 29 May 2026 15:19:15 -0400 Subject: [PATCH] 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. --- features/steps/cloud_aws_discover_steps.py | 6 +++--- features/steps/cloud_aws_session_steps.py | 14 +++++++------- features/steps/cloud_resources_steps.py | 18 ------------------ typings/boto3/__init__.pyi | 3 +-- typings/botocore/__init__.pyi | 6 +++--- typings/botocore/exceptions.pyi | 6 +++--- 6 files changed, 17 insertions(+), 36 deletions(-) diff --git a/features/steps/cloud_aws_discover_steps.py b/features/steps/cloud_aws_discover_steps.py index 5daba008b..b11dcb2a1 100644 --- a/features/steps/cloud_aws_discover_steps.py +++ b/features/steps/cloud_aws_discover_steps.py @@ -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())}" ) diff --git a/features/steps/cloud_aws_session_steps.py b/features/steps/cloud_aws_session_steps.py index d962d7ab7..dce835d36 100644 --- a/features/steps/cloud_aws_session_steps.py +++ b/features/steps/cloud_aws_session_steps.py @@ -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") diff --git a/features/steps/cloud_resources_steps.py b/features/steps/cloud_resources_steps.py index c348852b5..836f96ede 100644 --- a/features/steps/cloud_resources_steps.py +++ b/features/steps/cloud_resources_steps.py @@ -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") diff --git a/typings/boto3/__init__.pyi b/typings/boto3/__init__.pyi index 9da5d29ef..09598c4ce 100644 --- a/typings/boto3/__init__.pyi +++ b/typings/boto3/__init__.pyi @@ -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: ... diff --git a/typings/botocore/__init__.pyi b/typings/botocore/__init__.pyi index 8bf58dee5..93b79ce21 100644 --- a/typings/botocore/__init__.pyi +++ b/typings/botocore/__init__.pyi @@ -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: ... diff --git a/typings/botocore/exceptions.pyi b/typings/botocore/exceptions.pyi index 8bf58dee5..93b79ce21 100644 --- a/typings/botocore/exceptions.pyi +++ b/typings/botocore/exceptions.pyi @@ -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: ...