Skip to content

Commit 6df8a4b

Browse files
authored
Admin: Enable additional Ruff rules (E, F, G, W) (#9484)
1 parent 6085b0b commit 6df8a4b

File tree

11 files changed

+33
-18
lines changed

11 files changed

+33
-18
lines changed

moto/batch/models.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,9 @@ def run(self) -> None:
679679
try:
680680
import docker
681681
except ImportError as err:
682-
logger.error(f"Failed to run AWS Batch container {self.name}. Error {err}")
682+
logger.error(
683+
"Failed to run AWS Batch container %s. Error %s", self.name, err
684+
)
683685
self._mark_stopped(success=False)
684686
return
685687

@@ -929,13 +931,15 @@ def run(self) -> None:
929931

930932
except Exception as err:
931933
logger.error(
932-
f"Failed to run AWS Batch container {self.name}. Error {err}"
934+
"Failed to run AWS Batch container %s. Error %s", self.name, err
933935
)
934936
self._mark_stopped(success=False)
935937

936938
self._mark_stopped(success=True)
937939
except Exception as err:
938-
logger.error(f"Failed to run AWS Batch container {self.name}. Error {err}")
940+
logger.error(
941+
"Failed to run AWS Batch container %s. Error %s", self.name, err
942+
)
939943
self._mark_stopped(success=False)
940944
finally:
941945
for container in containers:
@@ -991,7 +995,9 @@ def _wait_for_dependencies(self) -> bool:
991995
successful_dependencies.add(dependent_id)
992996
if dependent_job.status == JobStatus.FAILED:
993997
logger.error(
994-
f"Terminating job {self.name} due to failed dependency {dependent_job.name}"
998+
"Terminating job %s due to failed dependency %s",
999+
self.name,
1000+
dependent_job.name,
9951001
)
9961002
self._mark_stopped(success=False)
9971003
return False

moto/cloudfront/responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def list_key_groups(self) -> TYPE_RESPONSE:
354354
<DefaultCacheBehavior>
355355
<TargetOriginId>{{ distribution.distribution_config.default_cache_behavior.target_origin_id }}</TargetOriginId>
356356
<TrustedSigners>
357-
<Enabled>{{ 'true' if distribution.distribution_config.default_cache_behavior.trusted_signers.acct_nums|length > 0 else 'false' }}</Enabled>
357+
<Enabled>{{ 'true' if distribution.distribution_config.default_cache_behavior.trusted_signers.acct_nums|length > 0 else 'false' }}</Enabled>
358358
<Quantity>{{ distribution.distribution_config.default_cache_behavior.trusted_signers.acct_nums|length }}</Quantity>
359359
<Items>
360360
{% for aws_account_number in distribution.distribution_config.default_cache_behavior.trusted_signers.acct_nums %}

moto/dynamodb/parsing/expressions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ def _parse_target_clause(self, factory_class):
6767
pos = self.token_pos
6868
fc = factory_class.__class__.__name__
6969
logger.debug(
70-
f"Move token pos {pos} to continue parsing with specific factory class {fc}"
70+
"Move token pos %s to continue parsing with specific factory class %s",
71+
pos,
72+
fc,
7173
)
7274
# noinspection PyProtectedMember
7375
ast, token_pos = factory_class(**self._initializer_args())._parse_with_pos()
7476
self.target_clauses.append(ast)
75-
logger.debug(f"Continue where previous parsing ended {token_pos}")
77+
logger.debug("Continue where previous parsing ended: %s", token_pos)
7678
self.token_pos = token_pos
7779

7880
@abstractmethod
@@ -353,7 +355,7 @@ def _parse_target_clause(self, factory_class):
353355
**self._initializer_args()
354356
)._parse_with_pos()
355357
self.target_nodes.append(ast)
356-
logger.debug(f"Continue where previous parsing ended {self.token_pos}")
358+
logger.debug("Continue where previous parsing ended: %s", self.token_pos)
357359

358360
def _parse(self):
359361
self._parse_target_clause(self._operand_factory_class())
@@ -552,7 +554,7 @@ def _parse(self):
552554
if len(self.target_clauses) == 0:
553555
nc = self._nestable_class().__name__
554556
nepc = self._nested_expression_parser_class().__name__
555-
logger.debug(f"Didn't encounter a single {nc} in {nepc}.")
557+
logger.debug("Didn't encounter a single %s in %s.", nc, nepc)
556558
self.raise_unexpected_token()
557559

558560
return self._create_node()

moto/iam/access_control.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ def __init__(
214214
action: str,
215215
):
216216
log.debug(
217-
f"Creating {self.__class__.__name__} with method={method}, path={path}, data={data}, headers={headers}"
217+
"Creating %s with method=%s, path=%s, data=%s, headers=%s",
218+
self.__class__.__name__,
219+
method,
220+
path,
221+
data,
222+
headers,
218223
)
219224
self.account_id = account_id
220225
self._method = method

moto/stepfunctions/parser/asl/component/state/exec/state_task/service/state_task_service_aws_sdk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def _normalise_service_error_name(service_name: str) -> str:
5656

5757
# Revert to returning the resource's service name and log the missing binding.
5858
LOG.warning(
59-
f"No normalised service error name for aws-sdk integration was found for service: '{service_name}'"
59+
"No normalised service error name for aws-sdk integration was found for service: '%s'",
60+
service_name,
6061
)
6162
return service_name
6263

moto/utilities/id_generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ def find_id_from_sources(
128128
if found_id := id_source(id_source_context):
129129
if found_id in existing_ids:
130130
log.debug(
131-
f"Found id {found_id} for resource {id_source_context.get('resource_identifier')}, "
132-
"but a resource already exists with this id."
131+
"Found id %s for resource %s, but a resource already exists with this id.",
132+
found_id,
133+
id_source_context.get("resource_identifier"),
133134
)
134135
else:
135136
return found_id

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ ignore = [
2424
"E501", # Line length
2525
"UP007", # Use X | Y for type annotations - should only be enabled when we support Python >= 3.10
2626
]
27-
extend-select = ["B", "C4", "I", "T201", "T203", "UP"]
27+
extend-select = ["B", "C4", "E", "F", "G", "I", "T", "UP", "W"]
2828

tests/test_athena/test_athena_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_athena_csv_result(bucket_name=None):
9696
k1 string,
9797
k2 string,
9898
k3 int
99-
)
99+
)
100100
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
101101
STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
102102
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'

tests/test_dynamodb/test_dynamodb_update_expressions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_update_different_map_elements_in_single_request(table_name=None):
3636
Key={"pk": "example_id"},
3737
UpdateExpression=(
3838
"""
39-
ADD
39+
ADD
4040
MyTotalCount :MyCount
4141
"""
4242
),

tests/test_mediapackagev2/test_interaction_mediapackage_v1_and_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
These tests are here simply to verify that, for MediaPackage, there is no overlap.
1313
14-
V1 Channels cannot be retrieved in V2, nor vice versa
14+
V1 Channels cannot be retrieved in V2, nor vice versa
1515
"""
1616

1717

0 commit comments

Comments
 (0)