Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make code ruffer #8541

Merged
merged 1 commit into from
Feb 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions moto/athena/models.py
Original file line number Diff line number Diff line change
@@ -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"]
]
)
2 changes: 1 addition & 1 deletion moto/config/exceptions.py
Original file line number Diff line number Diff line change
@@ -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",
)


3 changes: 1 addition & 2 deletions moto/config/models.py
Original file line number Diff line number Diff line change
@@ -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(
2 changes: 1 addition & 1 deletion moto/databrew/models.py
Original file line number Diff line number Diff line change
@@ -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 (
2 changes: 1 addition & 1 deletion moto/ec2/exceptions.py
Original file line number Diff line number Diff line change
@@ -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.",
)


3 changes: 1 addition & 2 deletions moto/logs/models.py
Original file line number Diff line number Diff line change
@@ -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(
3 changes: 1 addition & 2 deletions moto/route53resolver/models.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion moto/sagemaker/models.py
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion moto/secretsmanager/models.py
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion moto/sqs/exceptions.py
Original file line number Diff line number Diff line change
@@ -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}.",
)


3 changes: 1 addition & 2 deletions tests/test_ds/test_ds_simple_ad_directory.py
Original file line number Diff line number Diff line change
@@ -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])
4 changes: 1 addition & 3 deletions tests/test_dynamodb/test_dynamodb.py
Original file line number Diff line number Diff line change
@@ -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"]},
2 changes: 1 addition & 1 deletion tests/test_s3/test_s3.py
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion tests/test_ses/test_ses_boto3.py
Original file line number Diff line number Diff line change
@@ -1202,7 +1202,7 @@ def test_create_ses_template():
assert result["Template"]["TemplateName"] == "MyTemplate"
assert result["Template"]["SubjectPart"] == "Greetings, {{name}}!"
assert result["Template"]["HtmlPart"] == (
"<h1>Hello {{name}}," "</h1><p>Your favorite animal is {{favoriteanimal}}.</p>"
"<h1>Hello {{name}},</h1><p>Your favorite animal is {{favoriteanimal}}.</p>"
)
# get a template which is not present
with pytest.raises(ClientError) as ex:

Unchanged files with check annotations Beta

resource_type = resource_json["Type"]
resource_class = resource_class_from_type(resource_type)
if not resource_class:
warnings.warn(

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.13)

Tried to parse AWS::Cloud9::EnvironmentEC2 but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.10)

Tried to parse AWS::Cloud9::EnvironmentEC2 but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.10)

Tried to parse AWS::SQS::QueuePolicy but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.9)

Tried to parse AWS::Cloud9::EnvironmentEC2 but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.9)

Tried to parse AWS::SQS::QueuePolicy but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.11)

Tried to parse AWS::Cloud9::EnvironmentEC2 but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.11)

Tried to parse AWS::SQS::QueuePolicy but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.12)

Tried to parse AWS::Cloud9::EnvironmentEC2 but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.8)

Tried to parse AWS::Cloud9::EnvironmentEC2 but it's not supported by moto's CloudFormation implementation

Check warning on line 327 in moto/cloudformation/parsing.py

GitHub Actions / test / test (3.8)

Tried to parse AWS::SQS::QueuePolicy but it's not supported by moto's CloudFormation implementation
f"Tried to parse {resource_type} but it's not supported by moto's CloudFormation implementation"
)
return None # type: ignore[return-value]
layer_tar = zip2tar(layer_zip)
container.put_archive("/opt", layer_tar)
except zipfile.BadZipfile as e:
warnings.warn(f"Error extracting layer to Lambda: {e}")

Check warning on line 246 in moto/awslambda/models.py

GitHub Actions / test / test (3.13)

Error extracting layer to Lambda: File is not a zip file

Check warning on line 246 in moto/awslambda/models.py

GitHub Actions / test / test (3.10)

Error extracting layer to Lambda: File is not a zip file

Check warning on line 246 in moto/awslambda/models.py

GitHub Actions / test / test (3.9)

Error extracting layer to Lambda: File is not a zip file

Check warning on line 246 in moto/awslambda/models.py

GitHub Actions / test / test (3.11)

Error extracting layer to Lambda: File is not a zip file

Check warning on line 246 in moto/awslambda/models.py

GitHub Actions / test / test (3.12)

Error extracting layer to Lambda: File is not a zip file

Check warning on line 246 in moto/awslambda/models.py

GitHub Actions / test / test (3.8)

Error extracting layer to Lambda: File is not a zip file
finally:
container.remove(force=True)
# cryptography doesn't parse RFC4716 key format, so we have to convert it first
key_material = _convert_rfc4716(key_material)
public_key = serialization.load_ssh_public_key(key_material)

Check warning on line 759 in moto/ec2/utils.py

GitHub Actions / test / test (3.8)

SSH DSA keys are deprecated and will be removed in a future release.
if not isinstance(public_key, (RSAPublicKey, Ed25519PublicKey)):
raise ValueError("bad key")