generated from amazon-archives/__template_MIT-0
-
Couldn't load subscription status.
- Fork 456
Closed
Enhancement
Copy link
Labels
typingStatic typing definition related issues (mypy, pyright, etc.)Static typing definition related issues (mypy, pyright, etc.)
Description
Static type checker used
mypy (project's standard)
AWS Lambda function runtime
3.13
Powertools for AWS Lambda (Python) version
latest
Static type checker info
Docstring is correct, the underlying provider.set_timestamp() is correct as well, but Metrics.set_timestamp() only allows and int argument.
$ uvx --with aws_lambda_powertools mypy test.py
test.py:7:25: error: Argument 1 to "set_timestamp" of "Metrics" has incompatible type "datetime"; expected "int" [arg-type]
Found 1 error in 1 file (checked 1 source file)Code snippet
from datetime import UTC, datetime
from aws_lambda_powertools import Metrics
now = datetime.now(UTC)
Metrics().set_timestamp(int(now.timestamp() * 1_000)) # ok
Metrics().set_timestamp(now) # incompatible type
Metrics().provider.set_timestamp(int(now.timestamp() * 1_000)) # ok
Metrics().provider.set_timestamp(now) # okPossible Solution
Add datetime.datetime as a possible type to Metrics.set_timestamp(timestamp: int).
Metadata
Metadata
Assignees
Labels
typingStatic typing definition related issues (mypy, pyright, etc.)Static typing definition related issues (mypy, pyright, etc.)
Type
Projects
Status
Coming soon