From 5d4c42df5acba8982dcb0576e4f81d5482084bad Mon Sep 17 00:00:00 2001 From: Stefan Nordhausen Date: Fri, 31 Jan 2025 19:41:02 +0100 Subject: [PATCH] Make code ruffer I accidentally formatted the code with ruff version 0.9.4 and it produced some code simplifications that ruff 0.3.3 does not object to. --- moto/athena/models.py | 4 ++-- moto/config/exceptions.py | 2 +- moto/config/models.py | 3 +-- moto/databrew/models.py | 2 +- moto/ec2/exceptions.py | 2 +- moto/logs/models.py | 3 +-- moto/route53resolver/models.py | 3 +-- moto/sagemaker/models.py | 2 +- moto/secretsmanager/models.py | 2 +- moto/sqs/exceptions.py | 2 +- tests/test_ds/test_ds_simple_ad_directory.py | 3 +-- tests/test_dynamodb/test_dynamodb.py | 4 +--- tests/test_s3/test_s3.py | 2 +- tests/test_ses/test_ses_boto3.py | 2 +- 14 files changed, 15 insertions(+), 21 deletions(-) diff --git a/moto/athena/models.py b/moto/athena/models.py index c9cb498c18b2..4cb7a235a940 100644 --- a/moto/athena/models.py +++ b/moto/athena/models.py @@ -68,7 +68,7 @@ def __init__( self.configuration["EnforceWorkGroupConfiguration"] = True if "EngineVersion" not in self.configuration: self.configuration["EngineVersion"] = { - "EffectiveEngineVersion": "Athena engine " "version 3", + "EffectiveEngineVersion": "Athena engine version 3", "SelectedEngineVersion": "AUTO", } if "PublishCloudWatchMetricsEnabled" not in self.configuration: @@ -346,7 +346,7 @@ def _store_query_result_in_s3(self, exec_id: str) -> None: for row in self.query_results[exec_id].rows: query_result += ",".join( [ - f"\"{r['VarCharValue']}\"" if "VarCharValue" in r else "" + f'"{r["VarCharValue"]}"' if "VarCharValue" in r else "" for r in row["Data"] ] ) diff --git a/moto/config/exceptions.py b/moto/config/exceptions.py index bbbc09da1307..3b5ba667fb32 100644 --- a/moto/config/exceptions.py +++ b/moto/config/exceptions.py @@ -268,7 +268,7 @@ class InvalidResourceParameters(JsonRESTError): def __init__(self) -> None: super().__init__( "ValidationException", - "Both Resource ID and Resource Name " "cannot be specified in the request", + "Both Resource ID and Resource Name cannot be specified in the request", ) diff --git a/moto/config/models.py b/moto/config/models.py index 97b6fa94af8d..b8fb24883ba4 100644 --- a/moto/config/models.py +++ b/moto/config/models.py @@ -571,8 +571,7 @@ def __init__( # A more specific message will be used here instead. if not event_source: raise MissingRequiredConfigRuleParameterException( - "Missing required parameter in ConfigRule.SourceDetails: " - "'EventSource'" + "Missing required parameter in ConfigRule.SourceDetails: 'EventSource'" ) if event_source not in SourceDetail.EVENT_SOURCES: raise ValidationException( diff --git a/moto/databrew/models.py b/moto/databrew/models.py index 4bf1d9a275bb..e63a1064d5f7 100644 --- a/moto/databrew/models.py +++ b/moto/databrew/models.py @@ -103,7 +103,7 @@ def delete_recipe_version(self, recipe_name: str, recipe_version: str) -> None: and float(recipe_version) not in recipe.versions ): raise ResourceNotFoundException( - f"The recipe {recipe_name} version {recipe_version } wasn't found." + f"The recipe {recipe_name} version {recipe_version} wasn't found." ) if recipe_version in ( diff --git a/moto/ec2/exceptions.py b/moto/ec2/exceptions.py index 290842b5a77e..40bf77d0f610 100644 --- a/moto/ec2/exceptions.py +++ b/moto/ec2/exceptions.py @@ -547,7 +547,7 @@ class RulesPerSecurityGroupLimitExceededError(EC2ClientError): def __init__(self) -> None: super().__init__( "RulesPerSecurityGroupLimitExceeded", - "The maximum number of rules per security group " "has been reached.", + "The maximum number of rules per security group has been reached.", ) diff --git a/moto/logs/models.py b/moto/logs/models.py index 646cb10838b2..82cb82c7e203 100644 --- a/moto/logs/models.py +++ b/moto/logs/models.py @@ -1181,8 +1181,7 @@ def put_subscription_filter( else: # TODO: support Kinesis stream destinations raise InvalidParameterException( - f"Service '{service}' has not implemented for " - f"put_subscription_filter()" + f"Service '{service}' has not implemented for put_subscription_filter()" ) log_group.put_subscription_filter( diff --git a/moto/route53resolver/models.py b/moto/route53resolver/models.py index a4e41fe4591f..15eaf64c27a1 100644 --- a/moto/route53resolver/models.py +++ b/moto/route53resolver/models.py @@ -691,8 +691,7 @@ def delete_resolver_rule(self, resolver_rule_id: str) -> ResolverRule: ] if associations: raise ResourceInUseException( - "Please disassociate this resolver rule from VPC first " - "before deleting" + "Please disassociate this resolver rule from VPC first before deleting" ) self.tagger.delete_all_tags_for_resource(resolver_rule_id) diff --git a/moto/sagemaker/models.py b/moto/sagemaker/models.py index 4b38407aff42..43424cd99f1a 100644 --- a/moto/sagemaker/models.py +++ b/moto/sagemaker/models.py @@ -3939,7 +3939,7 @@ def format_time(x: Any) -> str: return ( x if isinstance(x, str) - else datetime.fromtimestamp(x).strftime("%Y-%m-%d " "%H:%M:%S") + else datetime.fromtimestamp(x).strftime("%Y-%m-%d %H:%M:%S") ) if created_after is not None: diff --git a/moto/secretsmanager/models.py b/moto/secretsmanager/models.py index 4f83f7c8de94..3f1f1ae892ef 100644 --- a/moto/secretsmanager/models.py +++ b/moto/secretsmanager/models.py @@ -722,7 +722,7 @@ def rotate_secret( if rotation_lambda_arn: if len(rotation_lambda_arn) > 2048: - msg = "RotationLambdaARN " "must <= 2048 characters long." + msg = "RotationLambdaARN must <= 2048 characters long." raise InvalidParameterException(msg) if rotation_rules: diff --git a/moto/sqs/exceptions.py b/moto/sqs/exceptions.py index a7f234e89b52..cf0ea95b3740 100644 --- a/moto/sqs/exceptions.py +++ b/moto/sqs/exceptions.py @@ -80,7 +80,7 @@ class TooManyEntriesInBatchRequest(RESTError): def __init__(self, number: int): super().__init__( "TooManyEntriesInBatchRequest", - "Maximum number of entries per request are 10. " f"You have sent {number}.", + f"Maximum number of entries per request are 10. You have sent {number}.", ) diff --git a/tests/test_ds/test_ds_simple_ad_directory.py b/tests/test_ds/test_ds_simple_ad_directory.py index 2bc71784fdc8..f8c3ea41ba93 100644 --- a/tests/test_ds/test_ds_simple_ad_directory.py +++ b/tests/test_ds/test_ds_simple_ad_directory.py @@ -196,8 +196,7 @@ def test_ds_create_directory_bad_subnets(): err = exc.value.response["Error"] assert err["Code"] == "ClientException" assert ( - "Invalid subnet ID(s). The two subnets must be in different " - "Availability Zones." + "Invalid subnet ID(s). The two subnets must be in different Availability Zones." ) in err["Message"] ec2_client.delete_subnet(SubnetId=subnets_same_region[0]) ec2_client.delete_subnet(SubnetId=subnets_same_region[1]) diff --git a/tests/test_dynamodb/test_dynamodb.py b/tests/test_dynamodb/test_dynamodb.py index 1905c4e8c4fb..9f5741926af4 100644 --- a/tests/test_dynamodb/test_dynamodb.py +++ b/tests/test_dynamodb/test_dynamodb.py @@ -2603,9 +2603,7 @@ def test_update_supports_complex_expression_attribute_values(): client.update_item( TableName="TestTable", Key={"SHA256": {"S": "sha-of-file"}}, - UpdateExpression=( - "SET MD5 = :md5," "MyStringSet = :string_set," "MyMap = :map" - ), + UpdateExpression=("SET MD5 = :md5,MyStringSet = :string_set,MyMap = :map"), ExpressionAttributeValues={ ":md5": {"S": "md5-of-file"}, ":string_set": {"SS": ["string1", "string2"]}, diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py index 4c8152e942bd..a9214c5d7609 100644 --- a/tests/test_s3/test_s3.py +++ b/tests/test_s3/test_s3.py @@ -2271,7 +2271,7 @@ def test_put_bucket_cors(): err_value = err.value assert err_value.response["Error"]["Code"] == "InvalidRequest" assert err_value.response["Error"]["Message"] == ( - "Found unsupported HTTP method in CORS config. " "Unsupported method is NOTREAL" + "Found unsupported HTTP method in CORS config. Unsupported method is NOTREAL" ) with pytest.raises(ClientError) as err: diff --git a/tests/test_ses/test_ses_boto3.py b/tests/test_ses/test_ses_boto3.py index 225b25c9a88d..427c628495d2 100644 --- a/tests/test_ses/test_ses_boto3.py +++ b/tests/test_ses/test_ses_boto3.py @@ -1202,7 +1202,7 @@ def test_create_ses_template(): assert result["Template"]["TemplateName"] == "MyTemplate" assert result["Template"]["SubjectPart"] == "Greetings, {{name}}!" assert result["Template"]["HtmlPart"] == ( - "

Hello {{name}}," "

Your favorite animal is {{favoriteanimal}}.

" + "

Hello {{name}},

Your favorite animal is {{favoriteanimal}}.

" ) # get a template which is not present with pytest.raises(ClientError) as ex: