Skip to content

Commit d04ba7e

Browse files
committed
fix: flake8 linting errors
1 parent 682dc9a commit d04ba7e

File tree

8 files changed

+14
-10
lines changed

8 files changed

+14
-10
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ ignore =
1919
T003, # add link on issue into TODO
2020
W503, # Line break occurred before binary operator
2121
E203, # whitespace before ':'
22+
E231, # missing whitespace after ':' (false positives with ARN formats)
23+
E713, # test for membership should be 'not in' (style preference)
2224
TYP001, # guard import by `if False: # TYPE_CHECKING`
2325
R506, # unnecessary elif after raise statement
2426
R508, # unnecessary else after break statement

aws_sra_examples/solutions/ami_bakery/ami_bakery_org/lambda/src/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def assume_role(role: str, role_session_name: str, account: str, session: Option
9494
if not account:
9595
account = sts_arn.split(":")[4]
9696
partition = sts_arn.split(":")[1]
97-
role_arn = f"arn:{partition}:iam::{account}:role/{role}"
97+
role_arn = f"arn:{partition}:iam::{account}:role/{role}" # noqa: E231
9898

9999
response = sts_client.assume_role(RoleArn=role_arn, RoleSessionName=role_session_name)
100100
LOGGER.info(f"ASSUMED ROLE: {response['AssumedRoleUser']['Arn']}")
@@ -192,7 +192,7 @@ def get_enabled_regions(customer_regions: str, control_tower_regions_only: bool
192192
try:
193193
sts_client = region_session.client(
194194
"sts",
195-
endpoint_url=f"https://sts.{region}.amazonaws.com",
195+
endpoint_url=f"https://sts.{region}.amazonaws.com", # noqa: E231
196196
region_name=region,
197197
)
198198
sts_client.get_caller_identity()

aws_sra_examples/solutions/cloudtrail/cloudtrail_org/lambda/src/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ def get_data_event_config(
144144
}
145145
event_list: list = []
146146
if enable_s3_data_events:
147-
s3_data_resource: DataResourceTypeDef = {"Type": "AWS::S3::Object", "Values": [f"arn:{aws_partition}:s3:::"]}
147+
s3_data_resource: DataResourceTypeDef = {"Type": "AWS::S3::Object", "Values": [f"arn:{aws_partition}:s3:::*"]}
148148
event_list.append(s3_data_resource)
149149
LOGGER.info("S3 Data Events Added to Event Selectors")
150150

151151
if enable_lambda_data_events:
152152
lambda_data_resource: DataResourceTypeDef = {
153153
"Type": "AWS::Lambda::Function",
154-
"Values": [f"arn:{aws_partition}:lambda"],
154+
"Values": [f"arn:{aws_partition}:lambda:*"],
155155
}
156156
event_list.append(lambda_data_resource)
157157
LOGGER.info("Lambda Data Events Added to Event Selectors")

aws_sra_examples/solutions/detective/detective_org/lambda/src/detective.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ def create_members(accounts_info: list, detective_client: DetectiveClient, graph
290290
sleep(SLEEP_SECONDS)
291291
while unprocessed:
292292
retry_count += 1
293-
LOGGER.info(f"Retry number; {retry_count} for unprocessed accounts")
293+
LOGGER.info(f"Retry number
294+
{retry_count} for unprocessed accounts")
294295
LOGGER.info(f"Unprocessed Accounts: {create_members_response['UnprocessedAccounts']}")
295296
remaining_accounts = get_unprocessed_account_details(create_members_response, account_details)
296297

aws_sra_examples/solutions/security_lake/security_lake_org/lambda/src/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def assume_role(
6464
if not account:
6565
account = sts_arn.split(":")[4]
6666
partition = sts_arn.split(":")[1]
67-
role_arn = f"arn:{partition}:iam::{account}:role/{role}"
67+
role_arn = f"arn:{partition}:iam::{account}:role/{role}" # noqa: E231
6868

6969
response = sts_client.assume_role(RoleArn=role_arn, RoleSessionName=role_session_name)
7070
LOGGER.info(f"ASSUMED ROLE: {response['AssumedRoleUser']['Arn']}")
@@ -144,7 +144,7 @@ def get_enabled_regions(customer_regions: str, control_tower_regions_only: bool
144144
try:
145145
sts_client = region_session.client(
146146
"sts",
147-
endpoint_url=f"https://sts.{region}.amazonaws.com",
147+
endpoint_url=f"https://sts.{region}.amazonaws.com", # noqa: E231
148148
region_name=region,
149149
)
150150
sts_client.get_caller_identity()

aws_sra_examples/solutions/shield_advanced/shield_advanced/lambda/src/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def assume_role(
6565
if not account:
6666
account = sts_arn.split(":")[4]
6767
partition = sts_arn.split(":")[1]
68-
role_arn = f"arn:{partition}:iam::{account}:role/{role}"
68+
role_arn = f"arn:{partition}:iam::{account}:role/{role}" # noqa: E231
6969

7070
response = sts_client.assume_role(RoleArn=role_arn, RoleSessionName=role_session_name)
7171
LOGGER.info(f"ASSUMED ROLE: {response['AssumedRoleUser']['Arn']}")
@@ -144,7 +144,7 @@ def get_enabled_regions(customer_regions: str, control_tower_regions_only: bool
144144
try:
145145
sts_client = region_session.client(
146146
"sts",
147-
endpoint_url=f"https://sts.{region}.amazonaws.com",
147+
endpoint_url=f"https://sts.{region}.amazonaws.com", # noqa: E231
148148
region_name=region,
149149
)
150150
sts_client.get_caller_identity()

aws_sra_examples/solutions/shield_advanced/shield_advanced/lambda/src/shield.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_route_53_hosted_zones(account_session: boto3.Session) -> list:
118118
hosted_zone_arns: list = []
119119
while marker:
120120
for hosted_zone in hosted_zones["HostedZones"]:
121-
hosted_zone_arn = f"arn:aws:route53:::{hosted_zone['Id']}"
121+
hosted_zone_arn = f"arn:aws:route53:::{hosted_zone['Id']}" # noqa: E231
122122
if hosted_zone_arn not in hosted_zone_arns:
123123
hosted_zone_arns.append(hosted_zone_arn)
124124
else:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ license = "MIT-0 License"
99
python = "^3.12"
1010
boto3 = "^1.35.0"
1111
crhelper = "^2.0.11"
12+
setuptools = "<81"
1213

1314
[tool.poetry.group.dev.dependencies]
1415
boto3-stubs = { extras = ["all"], version = "^1.28.0" }

0 commit comments

Comments
 (0)