@@ -54,38 +54,42 @@ def __init__(
5454 @property
5555 def role_assumable_by_compute_services (self ) -> list [str ]:
5656 """Determines whether or not the role is assumed from a compute service, and if so which ones."""
57- assumable_by_compute_services = []
58- for statement in self .statements :
59- if statement .role_assumable_by_compute_services :
60- assumable_by_compute_services .extend (statement .role_assumable_by_compute_services )
61- return assumable_by_compute_services
57+ return [
58+ principal
59+ for statement in self .statements
60+ if statement .role_assumable_by_compute_services
61+ for principal in statement .role_assumable_by_compute_services
62+ ]
6263
6364 @property
6465 def role_assumable_by_cross_account_principals (self ) -> list [str ]:
6566 """Determines whether or not the role can be assumed from principals in other accounts, and if so which ones."""
66- assumable_from_other_accounts = []
67- for statement in self .statements :
68- if statement .role_assumable_by_cross_account_principals :
69- assumable_from_other_accounts .extend (statement .role_assumable_by_cross_account_principals )
70- return assumable_from_other_accounts
67+ return [
68+ principal
69+ for statement in self .statements
70+ if statement .role_assumable_by_cross_account_principals
71+ for principal in statement .role_assumable_by_cross_account_principals
72+ ]
7173
7274 @property
7375 def role_assumable_by_any_principal (self ) -> list [str ]:
7476 """Determines whether or not the role can be assumed by any principal (*) or any AWS account root."""
75- any_principals = []
76- for statement in self .statements :
77- if statement .role_assumable_by_any_principal :
78- any_principals .extend (statement .role_assumable_by_any_principal )
79- return any_principals
77+ return [
78+ principal
79+ for statement in self .statements
80+ if statement .role_assumable_by_any_principal
81+ for principal in statement .role_assumable_by_any_principal
82+ ]
8083
8184 @property
8285 def role_assumable_by_any_principal_with_conditions (self ) -> list [str ]:
8386 """Determines whether or not the role can be assumed by any principal (*) or any AWS account root with conditions."""
84- any_principals_with_conditions = []
85- for statement in self .statements :
86- if statement .role_assumable_by_any_principal_with_conditions :
87- any_principals_with_conditions .extend (statement .role_assumable_by_any_principal_with_conditions )
88- return any_principals_with_conditions
87+ return [
88+ principal
89+ for statement in self .statements
90+ if statement .role_assumable_by_any_principal_with_conditions
91+ for principal in statement .role_assumable_by_any_principal_with_conditions
92+ ]
8993
9094
9195class AssumeRoleStatement (ResourceStatement ):
0 commit comments