Hi! I have a question about type hints in GetPolic...
# python
q
Hi! I have a question about type hints in GetPolicyDocumentStatementArgs. I noticed that
resources
parameter is typed as
Optional[Sequence[str]]
, but it accepts
Output[str]
at runtime without errors. Example:
Copy code
table = aws.dynamodb.Table("my-table",
    attributes=[aws.dynamodb.TableAttributeArgs(
        name="id",
        type="S"
    )],
    hash_key="id",
    read_capacity=1,
    write_capacity=1
)

policy = aws.iam.get_policy_document(statements=[
    aws.iam.GetPolicyDocumentStatementArgs(
        effect="Allow",
        actions=["dynamodb:GetItem"],
        resources=[table.arn]  # Works despite IDE warning
    )
])
# here I then create iam.Policy, iam.Role and iam.RolePolicyAttachment
I get IDE warning for
resources=[table.arn]
but it all works. What's going on here? Are type annotations wrong? Or should this not work and is it some "special magic case" ? Any insight appreciated. Thanks!
r
we heavily use
# type: ignore
a lot in our codebase for these cases where: • is way too hard to solve • the runtime works despite the typing errors
q
Thank you! So do I understand correctly that type annotations are wrong here?