Skip to content

Commit 34cab37

Browse files
authored
chore: Upgrade ruff to 0.1.* (#3446)
1 parent 8de601e commit 34cab37

10 files changed

+17
-18
lines changed

integration/combination/test_function_with_cwe_dlq_generated.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_function_with_cwe(self):
3636

3737
# checking policy action
3838
actions = dlq_policy_statement["Action"]
39-
action_list = actions if type(actions) == list else [actions]
39+
action_list = actions if isinstance(actions, list) == list else [actions]
4040
self.assertEqual(len(action_list), 1, "Only one action must be in dead-letter queue policy")
4141
self.assertEqual(
4242
action_list[0], "sqs:SendMessage", "Action referenced in dead-letter queue policy must be 'sqs:SendMessage'"

integration/combination/test_function_with_policy_templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_with_policy_templates(self):
1414
self.assertEqual(len(sqs_poller_policy), 1, "Only one statement must be in SQS Poller policy")
1515

1616
sqs_policy_statement = sqs_poller_policy[0]
17-
self.assertTrue(type(sqs_policy_statement["Resource"]) != list)
17+
self.assertFalse(isinstance(sqs_policy_statement["Resource"], list))
1818

1919
queue_url = self.get_physical_id_by_type("AWS::SQS::Queue")
2020
parts = queue_url.split("/")
@@ -32,7 +32,7 @@ def test_with_policy_templates(self):
3232
self.assertEqual(len(lambda_invoke_policy), 1, "One policies statements should be present")
3333

3434
lambda_policy_statement = lambda_invoke_policy[0]
35-
self.assertTrue(type(lambda_policy_statement["Resource"]) != list)
35+
self.assertFalse(isinstance(lambda_policy_statement["Resource"], list))
3636

3737
# NOTE: The resource ARN has "*" suffix to allow for any Lambda function version as well
3838
expected_function_suffix = "function:somename*"

integration/combination/test_state_machine_with_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ def _test_api_integration_with_state_machine(
7575

7676
start_execution_policy_statement = start_execution_policy[0]
7777

78-
self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
78+
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
7979
policy_action = start_execution_policy_statement["Action"]
8080
self.assertEqual(
8181
policy_action,
8282
"states:StartExecution",
8383
"Action referenced in event role policy must be 'states:StartExecution'",
8484
)
8585

86-
self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
86+
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
8787
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
8888
self.assertEqual(
8989
referenced_state_machine_arn,

integration/combination/test_state_machine_with_cwe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ def test_state_machine_with_cwe(self):
3434

3535
start_execution_policy_statement = start_execution_policy[0]
3636

37-
self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
37+
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
3838
policy_action = start_execution_policy_statement["Action"]
3939
self.assertEqual(
4040
policy_action,
4141
"states:StartExecution",
4242
"Action referenced in event role policy must be 'states:StartExecution'",
4343
)
4444

45-
self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
45+
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
4646
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
4747
self.assertEqual(
4848
referenced_state_machine_arn,

integration/combination/test_state_machine_with_cwe_dlq_generated.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ def test_state_machine_with_cwe(self):
3737

3838
start_execution_policy_statement = start_execution_policy[0]
3939

40-
self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
40+
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
4141
policy_action = start_execution_policy_statement["Action"]
4242
self.assertEqual(
4343
policy_action,
4444
"states:StartExecution",
4545
"Action referenced in event role policy must be 'states:StartExecution'",
4646
)
4747

48-
self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
48+
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
4949
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
5050
self.assertEqual(
5151
referenced_state_machine_arn,

integration/combination/test_state_machine_with_policy_templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_with_policy_templates(self):
2222
self.assertEqual(len(sqs_poller_policy), 1, "Only one statement must be in SQS Poller policy")
2323

2424
sqs_policy_statement = sqs_poller_policy[0]
25-
self.assertTrue(type(sqs_policy_statement["Resource"]) != list)
25+
self.assertFalse(isinstance(sqs_policy_statement["Resource"], list))
2626

2727
queue_url = self.get_physical_id_by_type("AWS::SQS::Queue")
2828
parts = queue_url.split("/")
@@ -40,7 +40,7 @@ def test_with_policy_templates(self):
4040
self.assertEqual(len(lambda_invoke_policy), 1, "One policies statements should be present")
4141

4242
lambda_policy_statement = lambda_invoke_policy[0]
43-
self.assertTrue(type(lambda_policy_statement["Resource"]) != list)
43+
self.assertFalse(isinstance(lambda_policy_statement["Resource"], list))
4444

4545
function_name = self.get_physical_id_by_type("AWS::Lambda::Function")
4646
# NOTE: The resource ARN has "*" suffix to allow for any Lambda function version as well

integration/combination/test_state_machine_with_schedule.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ def test_state_machine_with_schedule(self, template_file_path):
4545

4646
start_execution_policy_statement = start_execution_policy[0]
4747

48-
self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
48+
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
4949
policy_action = start_execution_policy_statement["Action"]
5050
self.assertEqual(
5151
policy_action,
5252
"states:StartExecution",
5353
"Action referenced in event role policy must be 'states:StartExecution'",
5454
)
5555

56-
self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
56+
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
5757
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
5858
self.assertEqual(
5959
referenced_state_machine_arn,

integration/combination/test_state_machine_with_schedule_dlq_and_retry_policy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ def test_state_machine_with_schedule(self):
4646

4747
start_execution_policy_statement = start_execution_policy[0]
4848

49-
self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
49+
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
5050
policy_action = start_execution_policy_statement["Action"]
5151
self.assertEqual(
5252
policy_action,
5353
"states:StartExecution",
5454
"Action referenced in event role policy must be 'states:StartExecution'",
5555
)
5656

57-
self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
57+
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
5858
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
5959
self.assertEqual(
6060
referenced_state_machine_arn,

integration/helpers/resource.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ def _resource_using_s3_events(resource: Dict[str, Any]) -> bool:
206206
def _get_all_event_sources(template_dict: Dict[str, Any]) -> Iterator[Dict[str, Any]]:
207207
resources = template_dict.get("Resources", {}).values()
208208
for resource in resources:
209-
for event in resource.get("Properties", {}).get("Events", {}).values():
210-
yield event
209+
yield from resource.get("Properties", {}).get("Events", {}).values()
211210

212211

213212
def _event_using_sns_filter_policy_scope(event: Dict[str, Any]) -> bool:

requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pytest-xdist>=2.5,<4
44
pytest-env>=0.6,<1
55
pytest-rerunfailures>=9.1,<12
66
pyyaml~=6.0
7-
ruff==0.0.284 # loose the requirement once it is more stable
7+
ruff~=0.1.0
88

99
# Test requirements
1010
pytest>=6.2,<8

0 commit comments

Comments
 (0)