Skip to content

Static typing: utilities.parameters.get_parameter #3507

Closed
@troyswanson

Description

@troyswanson

Static type checker used

pyright/pylance

AWS Lambda function runtime

3.10

Powertools for AWS Lambda (Python) version

2.29.1

Static type checker info

Argument of type "str | dict[Unknown, Unknown] | bytes" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "new"

Code snippet

from aws_lambda_powertools.utilities.parameters import get_parameter


param_value = get_parameter("/My/Parameter")
param_as_int = int(param_value)

Possible Solution

I believe this is happening because the get_parameter function can be configured via the transform argument to convert the param into a dictionary (if the response if a JSON string) or bytes (if the response is a base64 encoded string).

The type annotation for the function return can be overloaded depending on what value is used for that argument.

Metadata

Metadata

Assignees

Labels

parametersParameters utilitytypingStatic 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