Skip to content

chore: Upgrade ruff to 0.1.* #3446

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

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_function_with_cwe(self):

# checking policy action
actions = dlq_policy_statement["Action"]
action_list = actions if type(actions) == list else [actions]
action_list = actions if isinstance(actions, list) == list else [actions]
self.assertEqual(len(action_list), 1, "Only one action must be in dead-letter queue policy")
self.assertEqual(
action_list[0], "sqs:SendMessage", "Action referenced in dead-letter queue policy must be 'sqs:SendMessage'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_with_policy_templates(self):
self.assertEqual(len(sqs_poller_policy), 1, "Only one statement must be in SQS Poller policy")

sqs_policy_statement = sqs_poller_policy[0]
self.assertTrue(type(sqs_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(sqs_policy_statement["Resource"], list))

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

lambda_policy_statement = lambda_invoke_policy[0]
self.assertTrue(type(lambda_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(lambda_policy_statement["Resource"], list))

# NOTE: The resource ARN has "*" suffix to allow for any Lambda function version as well
expected_function_suffix = "function:somename*"
Expand Down
4 changes: 2 additions & 2 deletions integration/combination/test_state_machine_with_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ def _test_api_integration_with_state_machine(

start_execution_policy_statement = start_execution_policy[0]

self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
policy_action = start_execution_policy_statement["Action"]
self.assertEqual(
policy_action,
"states:StartExecution",
"Action referenced in event role policy must be 'states:StartExecution'",
)

self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
self.assertEqual(
referenced_state_machine_arn,
Expand Down
4 changes: 2 additions & 2 deletions integration/combination/test_state_machine_with_cwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def test_state_machine_with_cwe(self):

start_execution_policy_statement = start_execution_policy[0]

self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
policy_action = start_execution_policy_statement["Action"]
self.assertEqual(
policy_action,
"states:StartExecution",
"Action referenced in event role policy must be 'states:StartExecution'",
)

self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
self.assertEqual(
referenced_state_machine_arn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ def test_state_machine_with_cwe(self):

start_execution_policy_statement = start_execution_policy[0]

self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
policy_action = start_execution_policy_statement["Action"]
self.assertEqual(
policy_action,
"states:StartExecution",
"Action referenced in event role policy must be 'states:StartExecution'",
)

self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
self.assertEqual(
referenced_state_machine_arn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_with_policy_templates(self):
self.assertEqual(len(sqs_poller_policy), 1, "Only one statement must be in SQS Poller policy")

sqs_policy_statement = sqs_poller_policy[0]
self.assertTrue(type(sqs_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(sqs_policy_statement["Resource"], list))

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

lambda_policy_statement = lambda_invoke_policy[0]
self.assertTrue(type(lambda_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(lambda_policy_statement["Resource"], list))

function_name = self.get_physical_id_by_type("AWS::Lambda::Function")
# NOTE: The resource ARN has "*" suffix to allow for any Lambda function version as well
Expand Down
4 changes: 2 additions & 2 deletions integration/combination/test_state_machine_with_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def test_state_machine_with_schedule(self, template_file_path):

start_execution_policy_statement = start_execution_policy[0]

self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
policy_action = start_execution_policy_statement["Action"]
self.assertEqual(
policy_action,
"states:StartExecution",
"Action referenced in event role policy must be 'states:StartExecution'",
)

self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
self.assertEqual(
referenced_state_machine_arn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def test_state_machine_with_schedule(self):

start_execution_policy_statement = start_execution_policy[0]

self.assertTrue(type(start_execution_policy_statement["Action"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Action"], list))
policy_action = start_execution_policy_statement["Action"]
self.assertEqual(
policy_action,
"states:StartExecution",
"Action referenced in event role policy must be 'states:StartExecution'",
)

self.assertTrue(type(start_execution_policy_statement["Resource"]) != list)
self.assertFalse(isinstance(start_execution_policy_statement["Resource"], list))
referenced_state_machine_arn = start_execution_policy_statement["Resource"]
self.assertEqual(
referenced_state_machine_arn,
Expand Down
3 changes: 1 addition & 2 deletions integration/helpers/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ def _resource_using_s3_events(resource: Dict[str, Any]) -> bool:
def _get_all_event_sources(template_dict: Dict[str, Any]) -> Iterator[Dict[str, Any]]:
resources = template_dict.get("Resources", {}).values()
for resource in resources:
for event in resource.get("Properties", {}).get("Events", {}).values():
yield event
yield from resource.get("Properties", {}).get("Events", {}).values()


def _event_using_sns_filter_policy_scope(event: Dict[str, Any]) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pytest-xdist>=2.5,<4
pytest-env>=0.6,<1
pytest-rerunfailures>=9.1,<12
pyyaml~=6.0
ruff==0.0.284 # loose the requirement once it is more stable
ruff~=0.1.0

# Test requirements
pytest>=6.2,<8
Expand Down