Skip to content

Static typing: parameters get_secret #3909

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

Closed
TonySherman opened this issue Mar 7, 2024 · 1 comment · Fixed by #3910
Closed

Static typing: parameters get_secret #3909

TonySherman opened this issue Mar 7, 2024 · 1 comment · Fixed by #3910
Assignees
Labels
triage Pending triage from maintainers typing Static typing definition related issues (mypy, pyright, etc.)

Comments

@TonySherman
Copy link
Contributor

Static type checker used

pyright/pylance

AWS Lambda function runtime

3.9

Powertools for AWS Lambda (Python) version

latest

Static type checker info

Not running a static type checker but receiving this error from pyright in my editor

Code snippet

`secret = parameters.get_secret('secret_name', transform='json')`

`secret['SECRET']` will cause the following error:

Diagnostics:
1. Argument of type "Literal['SECRET']" cannot be assigned to parameter "__key" of type "SupportsIndex | slice" in function "__getitem__"
     Type "Literal['SECRET']" cannot be assigned to type "SupportsIndex | slice"
       "Literal['SECRET']" is incompatible with protocol "SupportsIndex"
         "__index__" is not present
       "Literal['SECRET']" is incompatible with "slice" [reportArgumentType]
2. No overloads for "__getitem__" match the provided arguments [reportCallIssue]
3. Argument of type "Literal['SECRET']" cannot be assigned to parameter "__key" of type "slice" in function "__getitem__"
     "Literal['SECRET']" is incompatible with "slice" [reportArgumentType]


### Possible Solution

This should be very similar to #3507 where adding overloads for each transform will fix this.
Copy link
Contributor

github-actions bot commented Mar 8, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Pending triage from maintainers typing Static typing definition related issues (mypy, pyright, etc.)
Projects
Status: Shipped
Development

Successfully merging a pull request may close this issue.

2 participants