Skip to content

Static typing: parameters get_secret #3909

@TonySherman

Description

@TonySherman

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.

Metadata

Metadata

Labels

triagePending triage from maintainerstypingStatic typing definition related issues (mypy, pyright, etc.)

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions