From ee4c5ed2d3d0e16bda44ee4a1879bee14c58c8c9 Mon Sep 17 00:00:00 2001 From: Akira Noda <61897166+tsugumi-sys@users.noreply.github.com> Date: Sun, 24 Mar 2024 02:52:48 +0900 Subject: [PATCH] Admin: Fix remaining ruff and pylint error (#7512) --- .github/workflows/build.yml | 2 +- moto/acmpca/models.py | 6 +- moto/apigateway/responses.py | 116 +++++++++--------- moto/apigatewayv2/responses.py | 20 +-- moto/appsync/responses.py | 12 +- moto/awslambda/responses.py | 20 +-- moto/cloudformation/parsing.py | 8 +- moto/cloudfront/responses.py | 12 +- moto/codecommit/models.py | 2 +- moto/databrew/responses.py | 12 +- moto/datasync/models.py | 2 +- moto/dynamodb/models/__init__.py | 4 +- moto/dynamodb/models/table.py | 8 +- moto/dynamodb/parsing/validators.py | 12 +- moto/dynamodb_v20111205/models.py | 4 +- moto/dynamodbstreams/models.py | 2 +- moto/ebs/responses.py | 8 +- moto/ec2/models/__init__.py | 2 +- moto/ec2/models/iam_instance_profile.py | 8 +- moto/ec2/models/instances.py | 4 +- moto/ec2/models/route_tables.py | 4 +- moto/ec2/models/security_groups.py | 4 +- .../ec2/models/transit_gateway_attachments.py | 20 +-- moto/ec2/models/vpcs.py | 16 +-- moto/ecr/models.py | 4 +- moto/ecs/models.py | 12 +- moto/elb/responses.py | 4 +- moto/emr/utils.py | 4 +- moto/events/models.py | 4 +- moto/firehose/models.py | 4 +- moto/glacier/responses.py | 12 +- moto/glue/responses.py | 32 ++--- moto/greengrass/models.py | 4 +- moto/greengrass/responses.py | 92 +++++++------- moto/iam/models.py | 4 +- moto/iam/policy_validation.py | 14 ++- moto/iotdata/models.py | 4 +- moto/kinesis/models.py | 4 +- moto/opsworks/models.py | 4 +- moto/rds/models.py | 8 +- moto/resourcegroupstaggingapi/models.py | 2 +- moto/route53/responses.py | 48 ++++---- moto/s3/models.py | 12 +- moto/s3control/responses.py | 12 +- moto/ses/responses.py | 6 +- moto/ses/template.py | 2 +- moto/stepfunctions/parser/models.py | 4 +- moto/sts/models.py | 2 +- moto/swf/models/domain.py | 4 +- tests/test_core/test_decorator_calls.py | 4 +- tests/test_logs/test_export_tasks.py | 8 +- .../test_resourcegroupstaggingapi.py | 2 - 52 files changed, 314 insertions(+), 310 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36d23cc7a..eefdb68da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,7 +68,7 @@ jobs: run: | pip install -r requirements-dev.txt - name: Lint - run: + run: | mkdir .mypy_cache make lint diff --git a/moto/acmpca/models.py b/moto/acmpca/models.py index 27a4565ec..6a2057ee5 100644 --- a/moto/acmpca/models.py +++ b/moto/acmpca/models.py @@ -136,9 +136,9 @@ class CertificateAuthority(BaseModel): "S3ObjectAcl", None ) if acl is None: - self.revocation_configuration["CrlConfiguration"][ - "S3ObjectAcl" - ] = "PUBLIC_READ" + self.revocation_configuration["CrlConfiguration"]["S3ObjectAcl"] = ( + "PUBLIC_READ" + ) else: if acl not in ["PUBLIC_READ", "BUCKET_OWNER_FULL_CONTROL"]: raise InvalidS3ObjectAclInCrlConfiguration(acl) diff --git a/moto/apigateway/responses.py b/moto/apigateway/responses.py index 353a326e5..6e52cb447 100644 --- a/moto/apigateway/responses.py +++ b/moto/apigateway/responses.py @@ -39,9 +39,9 @@ class APIGatewayResponse(BaseResponse): ).format(api_key_source=api_key_source), ) - def __validate_endpoint_configuration( + def __validate_endpoint_configuration( # type: ignore[return] self, endpoint_configuration: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: if endpoint_configuration and "types" in endpoint_configuration: invalid_types = list( set(endpoint_configuration["types"]) - set(ENDPOINT_CONFIGURATION_TYPES) @@ -57,9 +57,9 @@ class APIGatewayResponse(BaseResponse): ).format(endpoint_type=invalid_types[0]), ) - def restapis( + def restapis( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -105,9 +105,9 @@ class APIGatewayResponse(BaseResponse): return 200, {}, json.dumps(rest_api.to_dict()) - def __validte_rest_patch_operations( + def __validte_rest_patch_operations( # type: ignore[return] self, patch_operations: List[Dict[str, str]] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: for op in patch_operations: path = op["path"] if "apiKeySource" in path: @@ -142,9 +142,9 @@ class APIGatewayResponse(BaseResponse): return 200, {}, json.dumps(rest_api.to_dict()) - def resources( + def resources( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) function_id = self.path.replace("/restapis/", "", 1).split("/")[0] @@ -156,9 +156,9 @@ class APIGatewayResponse(BaseResponse): json.dumps({"item": [resource.to_dict() for resource in resources]}), ) - def gateway_response( + def gateway_response( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "PUT": return self.put_gateway_response() @@ -167,16 +167,16 @@ class APIGatewayResponse(BaseResponse): elif request.method == "DELETE": return self.delete_gateway_response() - def gateway_responses( + def gateway_responses( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "GET": return self.get_gateway_responses() - def resource_individual( + def resource_individual( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) function_id = self.path.replace("/restapis/", "", 1).split("/")[0] resource_id = self.path.split("/")[-1] @@ -268,9 +268,9 @@ class APIGatewayResponse(BaseResponse): return 204, {}, json.dumps(method_response.to_json()) # type: ignore[union-attr] raise Exception(f'Unexpected HTTP method "{self.method}"') - def restapis_authorizers( + def restapis_authorizers( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") restapi_id = url_path_parts[2] @@ -320,9 +320,9 @@ class APIGatewayResponse(BaseResponse): authorizers = self.backend.get_authorizers(restapi_id) return 200, {}, json.dumps({"item": [a.to_json() for a in authorizers]}) - def request_validators( + def request_validators( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") restapi_id = url_path_parts[2] @@ -342,9 +342,9 @@ class APIGatewayResponse(BaseResponse): ) return 201, {}, json.dumps(validator.to_dict()) - def request_validator_individual( + def request_validator_individual( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") restapi_id = url_path_parts[2] @@ -363,9 +363,9 @@ class APIGatewayResponse(BaseResponse): ) return 200, {}, json.dumps(validator.to_dict()) - def authorizers( + def authorizers( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") restapi_id = url_path_parts[2] @@ -384,9 +384,9 @@ class APIGatewayResponse(BaseResponse): self.backend.delete_authorizer(restapi_id, authorizer_id) return 202, {}, "{}" - def restapis_stages( + def restapis_stages( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") function_id = url_path_parts[2] @@ -417,9 +417,9 @@ class APIGatewayResponse(BaseResponse): stages = self.backend.get_stages(function_id) return 200, {}, json.dumps({"item": [s.to_json() for s in stages]}) - def restapis_stages_tags( + def restapis_stages_tags( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") function_id = url_path_parts[4] @@ -437,9 +437,9 @@ class APIGatewayResponse(BaseResponse): stage.tags.pop(tag, None) # type: ignore[union-attr] return 200, {}, json.dumps({"item": ""}) - def stages( + def stages( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") function_id = url_path_parts[2] @@ -476,9 +476,9 @@ class APIGatewayResponse(BaseResponse): } return 200, headers, json.dumps(body).encode("utf-8") - def integrations( + def integrations( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") function_id = url_path_parts[2] @@ -534,9 +534,9 @@ class APIGatewayResponse(BaseResponse): ) return 204, {}, json.dumps(integration_response.to_json()) - def integration_responses( + def integration_responses( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") function_id = url_path_parts[2] @@ -574,9 +574,9 @@ class APIGatewayResponse(BaseResponse): ) return 204, {}, json.dumps(integration_response.to_json()) - def deployments( + def deployments( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) function_id = self.path.replace("/restapis/", "", 1).split("/")[0] @@ -592,9 +592,9 @@ class APIGatewayResponse(BaseResponse): ) return 201, {}, json.dumps(deployment.to_json()) - def individual_deployment( + def individual_deployment( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") function_id = url_path_parts[2] @@ -607,9 +607,9 @@ class APIGatewayResponse(BaseResponse): deployment = self.backend.delete_deployment(function_id, deployment_id) return 202, {}, json.dumps(deployment.to_json()) - def apikeys( + def apikeys( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -649,9 +649,9 @@ class APIGatewayResponse(BaseResponse): return 200, {}, json.dumps(apikey_resp) - def usage_plans( + def usage_plans( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": usage_plan_response = self.backend.create_usage_plan(json.loads(self.body)) @@ -665,9 +665,9 @@ class APIGatewayResponse(BaseResponse): json.dumps({"item": [u.to_json() for u in usage_plans_response]}), ) - def usage_plan_individual( + def usage_plan_individual( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") @@ -686,9 +686,9 @@ class APIGatewayResponse(BaseResponse): ) return 200, {}, json.dumps(usage_plan_response.to_json()) - def usage_plan_keys( + def usage_plan_keys( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") @@ -707,9 +707,9 @@ class APIGatewayResponse(BaseResponse): json.dumps({"item": [u.to_json() for u in usage_plans_response]}), ) - def usage_plan_key_individual( + def usage_plan_key_individual( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") @@ -723,9 +723,9 @@ class APIGatewayResponse(BaseResponse): self.backend.delete_usage_plan_key(usage_plan_id, key_id) return 202, {}, "{}" - def domain_names( + def domain_names( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -780,9 +780,9 @@ class APIGatewayResponse(BaseResponse): msg = f'Method "{self.method}" for API GW domain names not implemented' return 404, {}, json.dumps({"error": msg}) - def models( + def models( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) rest_api_id = self.path.replace("/restapis/", "", 1).split("/")[0] @@ -817,9 +817,9 @@ class APIGatewayResponse(BaseResponse): return 200, {}, json.dumps(model_info.to_json()) return 200, {}, "{}" - def base_path_mappings( + def base_path_mappings( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") @@ -842,9 +842,9 @@ class APIGatewayResponse(BaseResponse): ) return 201, {}, json.dumps(base_path_mapping_resp.to_json()) - def base_path_mapping_individual( + def base_path_mapping_individual( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") @@ -866,9 +866,9 @@ class APIGatewayResponse(BaseResponse): ) return 200, {}, json.dumps(base_path_mapping.to_json()) - def vpc_link( + def vpc_link( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) url_path_parts = self.path.split("/") vpc_link_id = url_path_parts[-1] @@ -880,9 +880,9 @@ class APIGatewayResponse(BaseResponse): vpc_link = self.backend.get_vpc_link(vpc_link_id=vpc_link_id) return 200, {}, json.dumps(vpc_link.to_json()) - def vpc_links( + def vpc_links( # type: ignore[return] self, request: Any, full_url: str, headers: Dict[str, str] - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": diff --git a/moto/apigatewayv2/responses.py b/moto/apigatewayv2/responses.py index 16a00b37a..d10ae7d10 100644 --- a/moto/apigatewayv2/responses.py +++ b/moto/apigatewayv2/responses.py @@ -63,9 +63,9 @@ class ApiGatewayV2Response(BaseResponse): if self.method == "DELETE": return self.delete_cors_configuration() - def route_request_parameter( + def route_request_parameter( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "DELETE": @@ -105,9 +105,9 @@ class ApiGatewayV2Response(BaseResponse): if self.method == "POST": return self.create_integration() - def integration_response( + def integration_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "DELETE": @@ -117,9 +117,9 @@ class ApiGatewayV2Response(BaseResponse): if self.method == "PATCH": return self.update_integration_response() - def integration_responses( + def integration_responses( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -145,9 +145,9 @@ class ApiGatewayV2Response(BaseResponse): if self.method == "POST": return self.create_route() - def route_response( + def route_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "DELETE": @@ -155,9 +155,9 @@ class ApiGatewayV2Response(BaseResponse): if self.method == "GET": return self.get_route_response() - def route_responses( + def route_responses( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": diff --git a/moto/appsync/responses.py b/moto/appsync/responses.py index a3debe02f..27123dfed 100644 --- a/moto/appsync/responses.py +++ b/moto/appsync/responses.py @@ -27,9 +27,9 @@ class AppSyncResponse(BaseResponse): if request.method == "GET": return self.list_graphql_apis() - def graph_ql_individual( + def graph_ql_individual( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "GET": return self.get_graphql_api() @@ -45,18 +45,18 @@ class AppSyncResponse(BaseResponse): if request.method == "GET": return self.list_api_keys() - def schemacreation( + def schemacreation( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "POST": return self.start_schema_creation() if request.method == "GET": return self.get_schema_creation_status() - def api_key_individual( + def api_key_individual( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "DELETE": return self.delete_api_key() diff --git a/moto/awslambda/responses.py b/moto/awslambda/responses.py index 17d108a3a..94245b399 100644 --- a/moto/awslambda/responses.py +++ b/moto/awslambda/responses.py @@ -89,9 +89,9 @@ class LambdaResponse(BaseResponse): if request.method == "GET": return self._list_layers() - def layers_version( + def layers_version( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) layer_name = unquote(self.path.split("/")[-3]) layer_version = self.path.split("/")[-1] @@ -100,9 +100,9 @@ class LambdaResponse(BaseResponse): elif request.method == "GET": return self._get_layer_version(layer_name, layer_version) - def layers_versions( + def layers_versions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "GET": return self._get_layer_versions() @@ -190,9 +190,9 @@ class LambdaResponse(BaseResponse): else: raise ValueError("Cannot handle request") - def code_signing_config( + def code_signing_config( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "GET": return self._get_code_signing_config() @@ -212,9 +212,9 @@ class LambdaResponse(BaseResponse): else: raise ValueError("Cannot handle request") - def function_url_config( + def function_url_config( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: http_method = request.method self.setup_class(request, full_url, headers) @@ -417,9 +417,9 @@ class LambdaResponse(BaseResponse): return 204, {}, "" @staticmethod - def _set_configuration_qualifier( + def _set_configuration_qualifier( # type: ignore[misc] configuration: Dict[str, Any], function_name: str, qualifier: str - ) -> Dict[str, Any]: # type: ignore[misc] + ) -> Dict[str, Any]: # Qualifier may be explicitly passed or part of function name or ARN, extract it here if function_name.startswith("arn:aws"): # Extract from ARN diff --git a/moto/cloudformation/parsing.py b/moto/cloudformation/parsing.py index 8dbb9219c..6261d0d3f 100644 --- a/moto/cloudformation/parsing.py +++ b/moto/cloudformation/parsing.py @@ -343,8 +343,8 @@ def parse_resource_and_generate_name( generated_resource_name = generate_resource_name( resource_type, - resources_map["AWS::StackName"], - logical_id, # type: ignore[arg-type] + resources_map["AWS::StackName"], # type: ignore[arg-type] + logical_id, ) resource_name_property = resource_name_property_from_type(resource_type) @@ -438,11 +438,11 @@ def parse_and_delete_resource( ) -def parse_condition( +def parse_condition( # type: ignore[return] condition: Union[Dict[str, Any], bool], resources_map: "ResourceMap", condition_map: Dict[str, Any], -) -> bool: # type: ignore[return] +) -> bool: if isinstance(condition, bool): return condition diff --git a/moto/cloudfront/responses.py b/moto/cloudfront/responses.py index 0966ff63d..af54383db 100644 --- a/moto/cloudfront/responses.py +++ b/moto/cloudfront/responses.py @@ -40,18 +40,18 @@ class CloudFrontResponse(BaseResponse): if request.method == "GET": return self.list_tags_for_resource() - def origin_access_controls( + def origin_access_controls( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "POST": return self.create_origin_access_control() if request.method == "GET": return self.list_origin_access_controls() - def origin_access_control( + def origin_access_control( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "GET": return self.get_origin_access_control() @@ -86,9 +86,9 @@ class CloudFrontResponse(BaseResponse): response = template.render(distributions=distributions) return 200, {}, response - def individual_distribution( + def individual_distribution( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) distribution_id = full_url.split("/")[-1] if request.method == "DELETE": diff --git a/moto/codecommit/models.py b/moto/codecommit/models.py index 49eb5391e..184c0c495 100644 --- a/moto/codecommit/models.py +++ b/moto/codecommit/models.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional +from typing import Dict, Optional from moto.core.base_backend import BackendDict, BaseBackend from moto.core.common_models import BaseModel diff --git a/moto/databrew/responses.py b/moto/databrew/responses.py index 285ebfd29..e88a42ae4 100644 --- a/moto/databrew/responses.py +++ b/moto/databrew/responses.py @@ -29,9 +29,9 @@ class DataBrewResponse(BaseResponse): tags = self.parameters.get("Tags") return json.dumps( self.databrew_backend.create_recipe( - recipe_name, - recipe_description, - recipe_steps, + recipe_name, # type: ignore[arg-type] + recipe_description, # type: ignore[arg-type] + recipe_steps, # type: ignore[arg-type] tags, # type: ignore[arg-type] ).as_dict() ) @@ -102,7 +102,7 @@ class DataBrewResponse(BaseResponse): self.databrew_backend.update_recipe( recipe_name, - recipe_description, + recipe_description, # type: ignore[arg-type] recipe_steps, # type: ignore[arg-type] ) return json.dumps({"Name": recipe_name}) @@ -147,8 +147,8 @@ class DataBrewResponse(BaseResponse): ruleset = self.databrew_backend.update_ruleset( ruleset_name, - ruleset_description, - ruleset_rules, + ruleset_description, # type: ignore[arg-type] + ruleset_rules, # type: ignore[arg-type] tags, # type: ignore[arg-type] ) return json.dumps(ruleset.as_dict()) diff --git a/moto/datasync/models.py b/moto/datasync/models.py index 3834c65a7..429802c9d 100644 --- a/moto/datasync/models.py +++ b/moto/datasync/models.py @@ -1,5 +1,5 @@ from collections import OrderedDict -from typing import Any, Dict, List, Optional +from typing import Any, Dict, Optional from moto.core.base_backend import BackendDict, BaseBackend from moto.core.common_models import BaseModel diff --git a/moto/dynamodb/models/__init__.py b/moto/dynamodb/models/__init__.py index 4faa592ec..c47b97797 100644 --- a/moto/dynamodb/models/__init__.py +++ b/moto/dynamodb/models/__init__.py @@ -478,8 +478,8 @@ class DynamoDBBackend(BaseBackend): try: UpdateExpressionExecutor( validated_ast, - item, - expression_attribute_names, # type: ignore[arg-type] + item, # type: ignore[arg-type] + expression_attribute_names, ).execute() except ItemSizeTooLarge: raise ItemSizeToUpdateTooLarge() diff --git a/moto/dynamodb/models/table.py b/moto/dynamodb/models/table.py index d0056780f..acc2b1eaf 100644 --- a/moto/dynamodb/models/table.py +++ b/moto/dynamodb/models/table.py @@ -76,9 +76,9 @@ class LocalSecondaryIndex(SecondaryIndex): } @staticmethod - def create( + def create( # type: ignore[misc] dct: Dict[str, Any], table_key_attrs: List[str] - ) -> "LocalSecondaryIndex": # type: ignore[misc] + ) -> "LocalSecondaryIndex": return LocalSecondaryIndex( index_name=dct["IndexName"], schema=dct["KeySchema"], @@ -114,9 +114,9 @@ class GlobalSecondaryIndex(SecondaryIndex): } @staticmethod - def create( + def create( # type: ignore[misc] dct: Dict[str, Any], table_key_attrs: List[str] - ) -> "GlobalSecondaryIndex": # type: ignore[misc] + ) -> "GlobalSecondaryIndex": return GlobalSecondaryIndex( index_name=dct["IndexName"], schema=dct["KeySchema"], diff --git a/moto/dynamodb/parsing/validators.py b/moto/dynamodb/parsing/validators.py index 58cb67d09..bb5c52b4d 100644 --- a/moto/dynamodb/parsing/validators.py +++ b/moto/dynamodb/parsing/validators.py @@ -257,9 +257,9 @@ class UpdateExpressionFunctionEvaluator(DepthFirstTraverser): # type: ignore[mi raise NotImplementedError(f"Unsupported function for moto {function_name}") @classmethod - def get_list_from_ddb_typed_value( + def get_list_from_ddb_typed_value( # type: ignore[misc] cls, node: DDBTypedValue, function_name: str - ) -> DynamoType: # type: ignore[misc] + ) -> DynamoType: assert isinstance(node, DDBTypedValue) dynamo_value = node.get_value() assert isinstance(dynamo_value, DynamoType) @@ -324,9 +324,9 @@ class ExecuteOperations(DepthFirstTraverser): # type: ignore[misc] return dynamo_value @classmethod - def get_sum( + def get_sum( # type: ignore[misc] cls, left_operand: DynamoType, right_operand: DynamoType - ) -> DDBTypedValue: # type: ignore[misc] + ) -> DDBTypedValue: """ Args: left_operand(DynamoType): @@ -341,9 +341,9 @@ class ExecuteOperations(DepthFirstTraverser): # type: ignore[misc] raise IncorrectOperandType("+", left_operand.type) @classmethod - def get_subtraction( + def get_subtraction( # type: ignore[misc] cls, left_operand: DynamoType, right_operand: DynamoType - ) -> DDBTypedValue: # type: ignore[misc] + ) -> DDBTypedValue: """ Args: left_operand(DynamoType): diff --git a/moto/dynamodb_v20111205/models.py b/moto/dynamodb_v20111205/models.py index a3fb1b2b6..bbf23868e 100644 --- a/moto/dynamodb_v20111205/models.py +++ b/moto/dynamodb_v20111205/models.py @@ -166,8 +166,8 @@ class Table(BaseModel): hash_value = DynamoType(item_attrs.get(self.hash_key_attr)) # type: ignore[arg-type] if self.has_range_key: range_value: Optional[DynamoType] = DynamoType( - item_attrs.get(self.range_key_attr) - ) # type: ignore[arg-type] + item_attrs.get(self.range_key_attr) # type: ignore[arg-type] + ) else: range_value = None diff --git a/moto/dynamodbstreams/models.py b/moto/dynamodbstreams/models.py index 4833a2274..b41e2b663 100644 --- a/moto/dynamodbstreams/models.py +++ b/moto/dynamodbstreams/models.py @@ -129,7 +129,7 @@ class DynamoDBStreamsBackend(BaseBackend): shard_iterator = ShardIterator( self, - table.stream_shard, + table.stream_shard, # type: ignore[arg-type] shard_iterator_type, sequence_number, # type: ignore[arg-type] ) diff --git a/moto/ebs/responses.py b/moto/ebs/responses.py index 0482d9c4e..e2d726d4d 100644 --- a/moto/ebs/responses.py +++ b/moto/ebs/responses.py @@ -25,18 +25,18 @@ class EBSResponse(BaseResponse): if request.method == "POST": return self.start_snapshot() - def snapshot_block( + def snapshot_block( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers, use_raw_body=True) if request.method == "PUT": return self.put_snapshot_block(full_url, headers) if request.method == "GET": return self.get_snapshot_block() - def snapshot_blocks( + def snapshot_blocks( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "GET": return self.list_snapshot_blocks() diff --git a/moto/ec2/models/__init__.py b/moto/ec2/models/__init__.py index 9f96a95e9..03e2b3b9d 100644 --- a/moto/ec2/models/__init__.py +++ b/moto/ec2/models/__init__.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List +from typing import List from moto.core.base_backend import BackendDict, BaseBackend diff --git a/moto/ec2/models/iam_instance_profile.py b/moto/ec2/models/iam_instance_profile.py index f47cc022a..60f7f6d11 100644 --- a/moto/ec2/models/iam_instance_profile.py +++ b/moto/ec2/models/iam_instance_profile.py @@ -50,9 +50,9 @@ class IamInstanceProfileAssociationBackend: iam_association_id = random_iam_instance_profile_association_id() instance_profile = filter_iam_instance_profiles( - self.account_id, + self.account_id, # type: ignore[attr-defined] iam_instance_profile_arn, - iam_instance_profile_name, # type: ignore[attr-defined] + iam_instance_profile_name, ) if instance_id in self.iam_instance_profile_associations.keys(): @@ -127,9 +127,9 @@ class IamInstanceProfileAssociationBackend: iam_instance_profile_arn: Optional[str] = None, ) -> IamInstanceProfileAssociation: instance_profile = filter_iam_instance_profiles( - self.account_id, + self.account_id, # type: ignore[attr-defined] iam_instance_profile_arn, - iam_instance_profile_name, # type: ignore[attr-defined] + iam_instance_profile_name, ) iam_instance_profile_association = None diff --git a/moto/ec2/models/instances.py b/moto/ec2/models/instances.py index 26fb59249..615be6807 100644 --- a/moto/ec2/models/instances.py +++ b/moto/ec2/models/instances.py @@ -668,8 +668,8 @@ class InstanceBackend: raise InvalidInstanceTypeError(kwargs["instance_type"]) security_groups = [ - self.get_security_group_by_name_or_id(name) - for name in security_group_names # type: ignore[attr-defined] + self.get_security_group_by_name_or_id(name) # type: ignore[attr-defined] + for name in security_group_names ] for sg_id in kwargs.pop("security_group_ids", []): diff --git a/moto/ec2/models/route_tables.py b/moto/ec2/models/route_tables.py index 7b5226838..c063b359c 100644 --- a/moto/ec2/models/route_tables.py +++ b/moto/ec2/models/route_tables.py @@ -489,8 +489,8 @@ class RouteBackend: route.instance = self.get_instance(instance_id) if instance_id else None # type: ignore[attr-defined] route.interface = ( - self.get_network_interface(interface_id) if interface_id else None - ) # type: ignore[attr-defined] + self.get_network_interface(interface_id) if interface_id else None # type: ignore[attr-defined] + ) route.vpc_pcx = ( self.get_vpc_peering_connection(vpc_peering_connection_id) # type: ignore[attr-defined] if vpc_peering_connection_id diff --git a/moto/ec2/models/security_groups.py b/moto/ec2/models/security_groups.py index cd7ef503e..51b6bfd81 100644 --- a/moto/ec2/models/security_groups.py +++ b/moto/ec2/models/security_groups.py @@ -629,9 +629,9 @@ class SecurityGroupBackend: return results @staticmethod - def _match_sg_rules( + def _match_sg_rules( # type: ignore[misc] rules_list: List[SecurityRule], filters: Any - ) -> List[SecurityRule]: # type: ignore[misc] + ) -> List[SecurityRule]: results = [] for rule in rules_list: if rule.match_tags(filters): diff --git a/moto/ec2/models/transit_gateway_attachments.py b/moto/ec2/models/transit_gateway_attachments.py index df97bd56e..0b37d99d8 100644 --- a/moto/ec2/models/transit_gateway_attachments.py +++ b/moto/ec2/models/transit_gateway_attachments.py @@ -235,8 +235,8 @@ class TransitGatewayAttachmentBackend: if remove_subnet_ids: tgw_attachment.subnet_ids = [ # type: ignore[attr-defined] id - for id in tgw_attachment.subnet_ids - if id not in remove_subnet_ids # type: ignore[attr-defined] + for id in tgw_attachment.subnet_ids # type: ignore[attr-defined] + if id not in remove_subnet_ids ] if options: @@ -359,16 +359,16 @@ class TransitGatewayAttachmentBackend: # For cross-account peering, must be accepted by the accepter if ( requester_account_id != accepter_account_id - and self.account_id != accepter_account_id - ): # type: ignore[attr-defined] + and self.account_id != accepter_account_id # type: ignore[attr-defined] + ): raise InvalidParameterValueErrorPeeringAttachment( "accept", transit_gateway_attachment_id ) if ( requester_region_name != accepter_region_name - and self.region_name != accepter_region_name - ): # type: ignore[attr-defined] + and self.region_name != accepter_region_name # type: ignore[attr-defined] + ): raise InvalidParameterValueErrorPeeringAttachment( "accept", transit_gateway_attachment_id ) @@ -393,16 +393,16 @@ class TransitGatewayAttachmentBackend: if ( requester_account_id != accepter_account_id - and self.account_id != accepter_account_id - ): # type: ignore[attr-defined] + and self.account_id != accepter_account_id # type: ignore[attr-defined] + ): raise InvalidParameterValueErrorPeeringAttachment( "reject", transit_gateway_attachment_id ) if ( requester_region_name != accepter_region_name - and self.region_name != accepter_region_name - ): # type: ignore[attr-defined] + and self.region_name != accepter_region_name # type: ignore[attr-defined] + ): raise InvalidParameterValueErrorPeeringAttachment( "reject", transit_gateway_attachment_id ) diff --git a/moto/ec2/models/vpcs.py b/moto/ec2/models/vpcs.py index d4d856614..614c9ea90 100644 --- a/moto/ec2/models/vpcs.py +++ b/moto/ec2/models/vpcs.py @@ -1044,15 +1044,17 @@ class VPCBackend: # Return sensible defaults, for services that do not offer a custom implementation for aws_service in AWS_ENDPOINT_SERVICES: if aws_service not in COVERED_ENDPOINT_SERVICES: - service_configs = BaseBackend.default_vpc_endpoint_service_factory(region, zones, aws_service) + service_configs = BaseBackend.default_vpc_endpoint_service_factory( + region, zones, aws_service + ) DEFAULT_VPC_ENDPOINT_SERVICES[region].extend(service_configs) return DEFAULT_VPC_ENDPOINT_SERVICES[region] @staticmethod - def _matches_service_by_tags( + def _matches_service_by_tags( # type: ignore[misc] service: Dict[str, Any], filter_item: Dict[str, Any] - ) -> bool: # type: ignore[misc] + ) -> bool: """Return True if service tags are not filtered by their tags. Note that the API specifies a key of "Values" for a filter, but @@ -1084,11 +1086,11 @@ class VPCBackend: return matched @staticmethod - def _filter_endpoint_services( + def _filter_endpoint_services( # type: ignore[misc] service_names_filters: List[str], filters: List[Dict[str, Any]], services: List[Dict[str, Any]], - ) -> List[Dict[str, Any]]: # type: ignore[misc] + ) -> List[Dict[str, Any]]: """Return filtered list of VPC endpoint services.""" if not service_names_filters and not filters: return services @@ -1161,8 +1163,8 @@ class VPCBackend: The DryRun parameter is ignored. """ default_services = self._collect_default_endpoint_services( - self.account_id, - region, # type: ignore[attr-defined] + self.account_id, # type: ignore[attr-defined] + region, ) custom_services = [x.to_dict() for x in self.configurations.values()] # type: ignore all_services = default_services + custom_services diff --git a/moto/ecr/models.py b/moto/ecr/models.py index 09e4b810b..4ede050f4 100644 --- a/moto/ecr/models.py +++ b/moto/ecr/models.py @@ -403,9 +403,9 @@ class ECRBackend(BaseBackend): self.tagger = TaggingService(tag_name="tags") @staticmethod - def default_vpc_endpoint_service( + def default_vpc_endpoint_service( # type: ignore[misc] service_region: str, zones: List[str] - ) -> List[Dict[str, Any]]: # type: ignore[misc] + ) -> List[Dict[str, Any]]: """Default VPC endpoint service.""" docker_endpoint = { "AcceptanceRequired": False, diff --git a/moto/ecs/models.py b/moto/ecs/models.py index a48f390dd..72acea49f 100644 --- a/moto/ecs/models.py +++ b/moto/ecs/models.py @@ -1207,11 +1207,11 @@ class EC2ContainerServiceBackend(BaseBackend): return task_definition @staticmethod - def _validate_container_defs( + def _validate_container_defs( # type: ignore[misc] memory: Optional[str], container_definitions: List[Dict[str, Any]], requires_compatibilities: Optional[List[str]], - ) -> None: # type: ignore[misc] + ) -> None: # The capitalised keys are passed by Cloudformation for cd in container_definitions: if "name" not in cd and "Name" not in cd: @@ -1356,9 +1356,9 @@ class EC2ContainerServiceBackend(BaseBackend): return tasks @staticmethod - def _calculate_task_resource_requirements( + def _calculate_task_resource_requirements( # type: ignore[misc] task_definition: TaskDefinition, - ) -> Dict[str, Any]: # type: ignore[misc] + ) -> Dict[str, Any]: resource_requirements: Dict[str, Any] = { "CPU": 0, "MEMORY": 0, @@ -1400,10 +1400,10 @@ class EC2ContainerServiceBackend(BaseBackend): return resource_requirements @staticmethod - def _can_be_placed( + def _can_be_placed( # type: ignore[misc] container_instance: ContainerInstance, task_resource_requirements: Dict[str, Any], - ) -> bool: # type: ignore[misc] + ) -> bool: """ :param container_instance: The container instance trying to be placed onto diff --git a/moto/elb/responses.py b/moto/elb/responses.py index c1bd72d0a..5e8e42f35 100644 --- a/moto/elb/responses.py +++ b/moto/elb/responses.py @@ -405,7 +405,7 @@ class ELBResponse(BaseResponse): subnets = params.get("Subnets") all_subnets = self.elb_backend.attach_load_balancer_to_subnets( - load_balancer_name, + load_balancer_name, # type: ignore[arg-type] subnets, # type: ignore[arg-type] ) template = self.response_template(ATTACH_LB_TO_SUBNETS_TEMPLATE) @@ -417,7 +417,7 @@ class ELBResponse(BaseResponse): subnets = params.get("Subnets") all_subnets = self.elb_backend.detach_load_balancer_from_subnets( - load_balancer_name, + load_balancer_name, # type: ignore[arg-type] subnets, # type: ignore[arg-type] ) template = self.response_template(DETACH_LB_FROM_SUBNETS_TEMPLATE) diff --git a/moto/emr/utils.py b/moto/emr/utils.py index 1beec2969..18f070c85 100644 --- a/moto/emr/utils.py +++ b/moto/emr/utils.py @@ -455,9 +455,9 @@ class EmrSecurityGroupManager: pass @staticmethod - def _render_rules( + def _render_rules( # type: ignore[misc] rules: Any, managed_groups: Dict[str, Any] - ) -> List[Dict[str, Any]]: # type: ignore[misc] + ) -> List[Dict[str, Any]]: rendered_rules = copy.deepcopy(rules) for rule in rendered_rules: rule["group_name_or_id"] = managed_groups[rule["group_name_or_id"]].id diff --git a/moto/events/models.py b/moto/events/models.py index 251a06353..05261a5a6 100644 --- a/moto/events/models.py +++ b/moto/events/models.py @@ -1389,9 +1389,9 @@ class EventsBackend(BaseBackend): ) @staticmethod - def _condition_param_to_stmt_condition( + def _condition_param_to_stmt_condition( # type: ignore[misc] condition: Optional[Dict[str, Any]], - ) -> Optional[Dict[str, Any]]: # type: ignore[misc] + ) -> Optional[Dict[str, Any]]: if condition: key = condition["Key"] value = condition["Value"] diff --git a/moto/firehose/models.py b/moto/firehose/models.py index 4576a6d36..7ec291b7a 100644 --- a/moto/firehose/models.py +++ b/moto/firehose/models.py @@ -413,9 +413,9 @@ class FirehoseBackend(BaseBackend): } @staticmethod - def put_http_records( + def put_http_records( # type: ignore[misc] http_destination: Dict[str, Any], records: List[Dict[str, bytes]] - ) -> List[Dict[str, str]]: # type: ignore[misc] + ) -> List[Dict[str, str]]: """Put records to a HTTP destination.""" # Mostly copied from localstack url = http_destination["EndpointConfiguration"]["Url"] diff --git a/moto/glacier/responses.py b/moto/glacier/responses.py index 47e5f969b..c444d9ac7 100644 --- a/moto/glacier/responses.py +++ b/moto/glacier/responses.py @@ -37,9 +37,9 @@ class GlacierResponse(BaseResponse): self.setup_class(request, full_url, headers) return self._vault_response(request, full_url, headers) - def _vault_response( + def _vault_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: method = request.method vault_name = vault_from_glacier_url(full_url) @@ -103,9 +103,9 @@ class GlacierResponse(BaseResponse): self.setup_class(request, full_url, headers) return self._vault_archive_individual_response(request, full_url, headers) - def _vault_archive_individual_response( + def _vault_archive_individual_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: method = request.method vault_name = full_url.split("/")[-3] archive_id = full_url.split("/")[-1] @@ -121,9 +121,9 @@ class GlacierResponse(BaseResponse): self.setup_class(request, full_url, headers) return self._vault_jobs_response(request, full_url, headers) - def _vault_jobs_response( + def _vault_jobs_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: method = request.method if hasattr(request, "body"): body = request.body diff --git a/moto/glue/responses.py b/moto/glue/responses.py index 6c9aa1514..c1bf3997c 100644 --- a/moto/glue/responses.py +++ b/moto/glue/responses.py @@ -32,8 +32,10 @@ class GlueResponse(BaseResponse): if "CatalogId" in self.parameters: database_input["CatalogId"] = self.parameters.get("CatalogId") # type: ignore self.glue_backend.create_database( - database_name, database_input, self.parameters.get("Tags") - ) # type: ignore[arg-type] + database_name, + database_input, # type: ignore[arg-type] + self.parameters.get("Tags"), # type: ignore[arg-type] + ) return "" def get_database(self) -> str: @@ -136,8 +138,8 @@ class GlueResponse(BaseResponse): table_name = self.parameters.get("TableName") expression = self.parameters.get("Expression") partitions = self.glue_backend.get_partitions( - database_name, - table_name, + database_name, # type: ignore[arg-type] + table_name, # type: ignore[arg-type] expression, # type: ignore[arg-type] ) @@ -158,8 +160,8 @@ class GlueResponse(BaseResponse): partitions_to_get = self.parameters.get("PartitionsToGet") partitions = self.glue_backend.batch_get_partition( - database_name, - table_name, + database_name, # type: ignore[arg-type] + table_name, # type: ignore[arg-type] partitions_to_get, # type: ignore[arg-type] ) @@ -178,8 +180,8 @@ class GlueResponse(BaseResponse): table_name = self.parameters.get("TableName") partition_input = self.parameters.get("PartitionInputList") errors_output = self.glue_backend.batch_create_partition( - database_name, - table_name, + database_name, # type: ignore[arg-type] + table_name, # type: ignore[arg-type] partition_input, # type: ignore[arg-type] ) @@ -196,9 +198,9 @@ class GlueResponse(BaseResponse): part_to_update = self.parameters.get("PartitionValueList") self.glue_backend.update_partition( - database_name, - table_name, - part_input, + database_name, # type: ignore[arg-type] + table_name, # type: ignore[arg-type] + part_input, # type: ignore[arg-type] part_to_update, # type: ignore[arg-type] ) return "" @@ -209,8 +211,8 @@ class GlueResponse(BaseResponse): entries = self.parameters.get("Entries") errors_output = self.glue_backend.batch_update_partition( - database_name, - table_name, + database_name, # type: ignore[arg-type] + table_name, # type: ignore[arg-type] entries, # type: ignore[arg-type] ) @@ -234,8 +236,8 @@ class GlueResponse(BaseResponse): parts = self.parameters.get("PartitionsToDelete") errors_output = self.glue_backend.batch_delete_partition( - database_name, - table_name, + database_name, # type: ignore[arg-type] + table_name, # type: ignore[arg-type] parts, # type: ignore[arg-type] ) diff --git a/moto/greengrass/models.py b/moto/greengrass/models.py index b6f6b8110..c9162b8ee 100644 --- a/moto/greengrass/models.py +++ b/moto/greengrass/models.py @@ -916,9 +916,9 @@ class GreengrassBackend(BaseBackend): return False @staticmethod - def _validate_subscription_target_or_source( + def _validate_subscription_target_or_source( # type: ignore[misc] subscriptions: List[Dict[str, Any]], - ) -> None: # type: ignore[misc] + ) -> None: target_errors: List[str] = [] source_errors: List[str] = [] diff --git a/moto/greengrass/responses.py b/moto/greengrass/responses.py index 1b4de974f..b9e99769f 100644 --- a/moto/greengrass/responses.py +++ b/moto/greengrass/responses.py @@ -16,9 +16,9 @@ class GreengrassResponse(BaseResponse): def greengrass_backend(self) -> GreengrassBackend: return greengrass_backends[self.current_account][self.region] - def core_definitions( + def core_definitions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -45,9 +45,9 @@ class GreengrassResponse(BaseResponse): ) return 201, {"status": 201}, json.dumps(res.to_dict()) - def core_definition( + def core_definition( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -81,9 +81,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps({}) - def core_definition_versions( + def core_definition_versions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -110,9 +110,9 @@ class GreengrassResponse(BaseResponse): json.dumps({"Versions": [core_def_ver.to_dict() for core_def_ver in res]}), ) - def core_definition_version( + def core_definition_version( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -127,9 +127,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps(res.to_dict(include_detail=True)) - def device_definitions( + def device_definitions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -160,9 +160,9 @@ class GreengrassResponse(BaseResponse): ), ) - def device_definition_versions( + def device_definition_versions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -193,9 +193,9 @@ class GreengrassResponse(BaseResponse): ), ) - def device_definition( + def device_definition( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -229,9 +229,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps({}) - def device_definition_version( + def device_definition_version( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -246,9 +246,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps(res.to_dict(include_detail=True)) - def resource_definitions( + def resource_definitions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -273,9 +273,9 @@ class GreengrassResponse(BaseResponse): json.dumps({"Definitions": [i.to_dict() for i in res]}), ) - def resource_definition( + def resource_definition( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -309,9 +309,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps({}) - def resource_definition_versions( + def resource_definition_versions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -343,9 +343,9 @@ class GreengrassResponse(BaseResponse): ), ) - def resource_definition_version( + def resource_definition_version( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -360,9 +360,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps(res.to_dict()) - def function_definitions( + def function_definitions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -389,9 +389,9 @@ class GreengrassResponse(BaseResponse): ), ) - def function_definition( + def function_definition( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -425,9 +425,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps({}) - def function_definition_versions( + def function_definition_versions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -456,9 +456,9 @@ class GreengrassResponse(BaseResponse): versions = [i.to_dict() for i in res.values()] return 200, {"status": 200}, json.dumps({"Versions": versions}) - def function_definition_version( + def function_definition_version( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -473,9 +473,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps(res.to_dict()) - def subscription_definitions( + def subscription_definitions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -507,9 +507,9 @@ class GreengrassResponse(BaseResponse): ), ) - def subscription_definition( + def subscription_definition( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -543,9 +543,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps({}) - def subscription_definition_versions( + def subscription_definition_versions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -571,9 +571,9 @@ class GreengrassResponse(BaseResponse): versions = [i.to_dict() for i in res.values()] return 200, {"status": 200}, json.dumps({"Versions": versions}) - def subscription_definition_version( + def subscription_definition_version( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -643,9 +643,9 @@ class GreengrassResponse(BaseResponse): self.greengrass_backend.update_group(group_id=group_id, name=name) return 200, {"status": 200}, json.dumps({}) - def group_versions( + def group_versions( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": @@ -742,9 +742,9 @@ class GreengrassResponse(BaseResponse): json.dumps({"Deployments": deployments}), ) - def deployment_satus( + def deployment_satus( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "GET": @@ -760,9 +760,9 @@ class GreengrassResponse(BaseResponse): ) return 200, {"status": 200}, json.dumps(res.to_dict()) - def deployments_reset( + def deployments_reset( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if self.method == "POST": diff --git a/moto/iam/models.py b/moto/iam/models.py index 0cb6a61f1..22a26b643 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -463,9 +463,9 @@ class AWSManagedPolicy(ManagedPolicy): """AWS-managed policy.""" @classmethod - def from_data( + def from_data( # type: ignore[misc] cls, name: str, account_id: str, data: Dict[str, Any] - ) -> "AWSManagedPolicy": # type: ignore[misc] + ) -> "AWSManagedPolicy": return cls( name, account_id=account_id, diff --git a/moto/iam/policy_validation.py b/moto/iam/policy_validation.py index 95dd75772..5d47994a7 100644 --- a/moto/iam/policy_validation.py +++ b/moto/iam/policy_validation.py @@ -222,9 +222,10 @@ class BaseIAMPolicyValidator: ) @staticmethod - def _validate_string_or_list_of_strings_syntax( - statement: Dict[str, Any], key: str - ) -> None: # type: ignore[misc] + def _validate_string_or_list_of_strings_syntax( # type: ignore[misc] + statement: Dict[str, Any], + key: str, + ) -> None: if key in statement: assert isinstance(statement[key], (str, list)) if isinstance(statement[key], list): @@ -456,9 +457,10 @@ class BaseIAMPolicyValidator: assert resource[2] != "" @staticmethod - def _legacy_parse_condition( - condition_key: str, condition_value: Dict[str, Any] - ) -> None: # type: ignore[misc] + def _legacy_parse_condition( # type: ignore[misc] + condition_key: str, + condition_value: Dict[str, Any], + ) -> None: stripped_condition_key = IAMPolicyDocumentValidator._strip_condition_key( condition_key ) diff --git a/moto/iotdata/models.py b/moto/iotdata/models.py index 4a17ca81a..cb4b7cce1 100644 --- a/moto/iotdata/models.py +++ b/moto/iotdata/models.py @@ -44,9 +44,9 @@ class FakeShadow(BaseModel): ) @classmethod - def create_from_previous_version( + def create_from_previous_version( # type: ignore[misc] cls, previous_shadow: Optional["FakeShadow"], payload: Optional[Dict[str, Any]] - ) -> "FakeShadow": # type: ignore[misc] + ) -> "FakeShadow": """ set None to payload when you want to delete shadow """ diff --git a/moto/kinesis/models.py b/moto/kinesis/models.py index cb61030d3..c683e30b4 100644 --- a/moto/kinesis/models.py +++ b/moto/kinesis/models.py @@ -734,8 +734,8 @@ class KinesisBackend(BaseBackend): data = record.get("Data") sequence_number, shard_id = stream.put_record( - partition_key, - explicit_hash_key, + partition_key, # type: ignore[arg-type] + explicit_hash_key, # type: ignore[arg-type] data, # type: ignore[arg-type] ) response["Records"].append( diff --git a/moto/opsworks/models.py b/moto/opsworks/models.py index cf153a175..913c1b492 100644 --- a/moto/opsworks/models.py +++ b/moto/opsworks/models.py @@ -588,9 +588,9 @@ class OpsWorksBackend(BaseBackend): raise ResourceNotFoundException(", ".join(unknown_apps)) return [self.apps[id].to_dict() for id in app_ids] - def describe_instances( + def describe_instances( # type: ignore[return] self, instance_ids: List[str], layer_id: str, stack_id: str - ) -> List[Dict[str, Any]]: # type: ignore[return] + ) -> List[Dict[str, Any]]: if len(list(filter(None, (instance_ids, layer_id, stack_id)))) != 1: raise ValidationException( "Please provide either one or more " diff --git a/moto/rds/models.py b/moto/rds/models.py index bf151de9b..3eccad7f2 100644 --- a/moto/rds/models.py +++ b/moto/rds/models.py @@ -2754,9 +2754,9 @@ class RDSBackend(BaseBackend): "InvalidParameterValue", f"Invalid resource name: {arn}" ) - def add_tags_to_resource( + def add_tags_to_resource( # type: ignore[return] self, arn: str, tags: List[Dict[str, str]] - ) -> List[Dict[str, str]]: # type: ignore[return] + ) -> List[Dict[str, str]]: if self.arn_regex.match(arn): arn_breakdown = arn.split(":") resource_type = arn_breakdown[-2] @@ -2813,9 +2813,9 @@ class RDSBackend(BaseBackend): raise InvalidParameterCombination(str(e)) @staticmethod - def _merge_tags( + def _merge_tags( # type: ignore[misc] old_tags: List[Dict[str, Any]], new_tags: List[Dict[str, Any]] - ) -> List[Dict[str, Any]]: # type: ignore[misc] + ) -> List[Dict[str, Any]]: tags_dict = dict() tags_dict.update({d["Key"]: d["Value"] for d in old_tags}) tags_dict.update({d["Key"]: d["Value"] for d in new_tags}) diff --git a/moto/resourcegroupstaggingapi/models.py b/moto/resourcegroupstaggingapi/models.py index b2b2f33cb..c8f48559a 100644 --- a/moto/resourcegroupstaggingapi/models.py +++ b/moto/resourcegroupstaggingapi/models.py @@ -23,8 +23,8 @@ from moto.s3.models import S3Backend, s3_backends from moto.sns.models import SNSBackend, sns_backends from moto.sqs.models import SQSBackend, sqs_backends from moto.ssm.models import SimpleSystemManagerBackend, ssm_backends -from moto.workspaces.models import WorkSpacesBackend, workspaces_backends from moto.utilities.tagging_service import TaggingService +from moto.workspaces.models import WorkSpacesBackend, workspaces_backends # Left: EC2 ElastiCache RDS ELB CloudFront Lambda EMR Glacier Kinesis Redshift Route53 # StorageGateway DynamoDB MachineLearning ACM DirectConnect DirectoryService CloudHSM diff --git a/moto/route53/responses.py b/moto/route53/responses.py index 084c003f2..cc7e822b4 100644 --- a/moto/route53/responses.py +++ b/moto/route53/responses.py @@ -36,9 +36,9 @@ class Route53(BaseResponse): def backend(self) -> Route53Backend: return route53_backends[self.current_account]["global"] - def list_or_create_hostzone_response( + def list_or_create_hostzone_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) # Set these here outside the scope of the try/except @@ -136,9 +136,9 @@ class Route53(BaseResponse): template = Template(GET_HOSTED_ZONE_COUNT_RESPONSE) return 200, headers, template.render(zone_count=num_zones, xmlns=XMLNS) - def get_or_delete_hostzone_response( + def get_or_delete_hostzone_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) zoneid = self.parsed_url.path.rstrip("/").rsplit("/", 1)[1] @@ -158,9 +158,9 @@ class Route53(BaseResponse): template = Template(UPDATE_HOSTED_ZONE_COMMENT_RESPONSE) return 200, headers, template.render(zone=zone) - def get_dnssec_response( + def get_dnssec_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: # returns static response # TODO: implement enable/disable dnssec apis self.setup_class(request, full_url, headers) @@ -212,9 +212,9 @@ class Route53(BaseResponse): template = Template(DISASSOCIATE_VPC_RESPONSE) return 200, headers, template.render(comment=comment) - def rrset_response( + def rrset_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) method = request.method @@ -285,9 +285,9 @@ class Route53(BaseResponse): ) return 200, headers, r_template - def health_check_response1( + def health_check_response1( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) method = request.method @@ -327,9 +327,9 @@ class Route53(BaseResponse): template.render(health_checks=health_checks, xmlns=XMLNS), ) - def health_check_response2( + def health_check_response2( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) method = request.method @@ -365,9 +365,9 @@ class Route53(BaseResponse): template = Template(UPDATE_HEALTH_CHECK_RESPONSE) return 200, headers, template.render(health_check=health_check) - def health_check_status_response( + def health_check_status_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) method = request.method @@ -402,9 +402,9 @@ class Route53(BaseResponse): f"The action for {action} has not been implemented for route 53" ) - def list_or_change_tags_for_resource_request( + def list_or_change_tags_for_resource_request( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) id_ = self.parsed_url.path.split("/")[-1] @@ -439,9 +439,9 @@ class Route53(BaseResponse): template = Template(GET_CHANGE_RESPONSE) return 200, headers, template.render(change_id=change_id, xmlns=XMLNS) - def list_or_create_query_logging_config_response( + def list_or_create_query_logging_config_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "POST": @@ -488,9 +488,9 @@ class Route53(BaseResponse): ), ) - def get_or_delete_query_logging_config_response( + def get_or_delete_query_logging_config_response( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) query_logging_config_id = self.parsed_url.path.rstrip("/").rsplit("/", 1)[1] @@ -509,9 +509,9 @@ class Route53(BaseResponse): self.backend.delete_query_logging_config(query_logging_config_id) return 200, headers, "" - def reusable_delegation_sets( + def reusable_delegation_sets( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "GET": delegation_sets = self.backend.list_reusable_delegation_sets() @@ -541,9 +541,9 @@ class Route53(BaseResponse): template.render(delegation_set=delegation_set), ) - def reusable_delegation_set( + def reusable_delegation_set( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) ds_id = self.parsed_url.path.rstrip("/").rsplit("/")[-1] if request.method == "GET": diff --git a/moto/s3/models.py b/moto/s3/models.py index f133648ba..bdfa9e6fe 100644 --- a/moto/s3/models.py +++ b/moto/s3/models.py @@ -374,13 +374,13 @@ class FakeKey(BaseModel, ManagedState): now = utcnow() try: until = datetime.datetime.strptime( - self.lock_until, - "%Y-%m-%dT%H:%M:%SZ", # type: ignore + self.lock_until, # type: ignore + "%Y-%m-%dT%H:%M:%SZ", ) except ValueError: until = datetime.datetime.strptime( - self.lock_until, - "%Y-%m-%dT%H:%M:%S.%fZ", # type: ignore + self.lock_until, # type: ignore + "%Y-%m-%dT%H:%M:%S.%fZ", ) if until > now: @@ -478,11 +478,11 @@ class FakeMultipart(BaseModel): raise NoSuchUpload(upload_id=part_id) key = FakeKey( - part_id, + part_id, # type: ignore value, account_id=self.account_id, encryption=self.sse_encryption, - kms_key_id=self.kms_key_id, # type: ignore + kms_key_id=self.kms_key_id, ) if part_id in self.parts: # We're overwriting the current part - dispose of it first diff --git a/moto/s3control/responses.py b/moto/s3control/responses.py index 60976731c..8bc79de6c 100644 --- a/moto/s3control/responses.py +++ b/moto/s3control/responses.py @@ -19,9 +19,9 @@ class S3ControlResponse(BaseResponse): def backend(self) -> S3ControlBackend: return s3control_backends[self.current_account]["global"] - def public_access_block( + def public_access_block( # type: ignore self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) try: if request.method == "GET": @@ -70,9 +70,9 @@ class S3ControlResponse(BaseResponse): if request.method == "DELETE": return self.delete_access_point(full_url) - def access_point_policy( + def access_point_policy( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "PUT": return self.create_access_point_policy(full_url) @@ -81,9 +81,9 @@ class S3ControlResponse(BaseResponse): if request.method == "DELETE": return self.delete_access_point_policy(full_url) - def access_point_policy_status( + def access_point_policy_status( # type: ignore[return] self, request: Any, full_url: str, headers: Any - ) -> TYPE_RESPONSE: # type: ignore[return] + ) -> TYPE_RESPONSE: self.setup_class(request, full_url, headers) if request.method == "PUT": return self.create_access_point(full_url) diff --git a/moto/ses/responses.py b/moto/ses/responses.py index 85f72eb63..8eba94f50 100644 --- a/moto/ses/responses.py +++ b/moto/ses/responses.py @@ -143,9 +143,9 @@ class EmailResponse(BaseResponse): message = self.backend.send_bulk_templated_email( source, - template, - template_data, - destinations, # type: ignore + template, # type: ignore + template_data, # type: ignore + destinations, ) template = self.response_template(SEND_BULK_TEMPLATED_EMAIL_RESPONSE) result = template.render(message=message) diff --git a/moto/ses/template.py b/moto/ses/template.py index 91f3a0474..3a615cb5a 100644 --- a/moto/ses/template.py +++ b/moto/ses/template.py @@ -46,7 +46,7 @@ class EachBlockProcessor(BlockProcessor): _processor = get_processor(self.tokenizer)( self.template, - template_data, + template_data, # type: ignore self.tokenizer, # type: ignore ) # If we've reached the end, we should stop processing diff --git a/moto/stepfunctions/parser/models.py b/moto/stepfunctions/parser/models.py index a2c1af363..833e45d2e 100644 --- a/moto/stepfunctions/parser/models.py +++ b/moto/stepfunctions/parser/models.py @@ -106,9 +106,9 @@ class StepFunctionsParserBackend(StepFunctionBackend): raise InvalidToken() def send_task_success( - self, task_token: TaskToken, output: SensitiveData + self, task_token: TaskToken, outcome: SensitiveData ) -> SendTaskSuccessOutput: - outcome = CallbackOutcomeSuccess(callback_id=task_token, output=output) + outcome = CallbackOutcomeSuccess(callback_id=task_token, output=outcome) running_executions = self._get_executions(ExecutionStatus.RUNNING) for execution in running_executions: try: diff --git a/moto/sts/models.py b/moto/sts/models.py index 1ff40ae00..5fbb9cfb1 100644 --- a/moto/sts/models.py +++ b/moto/sts/models.py @@ -1,7 +1,7 @@ import datetime import re from base64 import b64decode -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, List, Optional, Tuple import xmltodict diff --git a/moto/swf/models/domain.py b/moto/swf/models/domain.py index a78935430..01c9011ad 100644 --- a/moto/swf/models/domain.py +++ b/moto/swf/models/domain.py @@ -61,9 +61,9 @@ class Domain(BaseModel): "configuration": {"workflowExecutionRetentionPeriodInDays": self.retention}, } - def get_type( + def get_type( # type: ignore self, kind: str, name: str, version: str, ignore_empty: bool = False - ) -> "GenericType": # type: ignore + ) -> "GenericType": try: return self.types[kind][name][version] except KeyError: diff --git a/tests/test_core/test_decorator_calls.py b/tests/test_core/test_decorator_calls.py index 58bc2c22c..6592d15f4 100644 --- a/tests/test_core/test_decorator_calls.py +++ b/tests/test_core/test_decorator_calls.py @@ -85,9 +85,9 @@ def test_decorater_wrapped_gets_set() -> None: Moto decorator's __wrapped__ should get set to the tests function """ assert ( - test_decorater_wrapped_gets_set.__wrapped__.__name__ + test_decorater_wrapped_gets_set.__wrapped__.__name__ # type: ignore == "test_decorater_wrapped_gets_set" - ) # type: ignore + ) @mock_aws diff --git a/tests/test_logs/test_export_tasks.py b/tests/test_logs/test_export_tasks.py index 6bd95de57..17d2a6f7c 100644 --- a/tests/test_logs/test_export_tasks.py +++ b/tests/test_logs/test_export_tasks.py @@ -143,8 +143,8 @@ def test_create_export_task_happy_path(logs, s3, log_group_name, bucket_name): @pytest.mark.aws_verified def test_create_export_task_raises_ClientError_when_bucket_not_found( logs, - log_group_name, # pylint: disable=redefined-outer-name -): + log_group_name, +): # pylint: disable=redefined-outer-name destination = "368a7022dea3dd621" fromTime = 1611316574 to = 1642852574 @@ -166,8 +166,8 @@ def test_create_export_task_raises_ClientError_when_bucket_not_found( @pytest.mark.aws_verified def test_create_export_raises_ResourceNotFoundException_log_group_not_found( logs, - bucket_name, # pylint: disable=redefined-outer-name -): + bucket_name, +): # pylint: disable=redefined-outer-name with pytest.raises(logs.exceptions.ResourceNotFoundException) as exc: logs.create_export_task( logGroupName=f"/aws/nonexisting/{str(uuid4())[0:6]}", diff --git a/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py b/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py index 1a5d9bb11..fe6ad6147 100644 --- a/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py +++ b/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py @@ -886,8 +886,6 @@ def test_get_resources_sns(): @mock_aws def test_get_resources_ssm(): - import json - import yaml from tests.test_ssm.test_ssm_docs import _get_yaml_template