-
Notifications
You must be signed in to change notification settings - Fork 441
Closed
Labels
loggertypingStatic 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.10
Powertools for AWS Lambda (Python) version
latest
Static type checker info
Output
error: Call to untyped function "append_keys" in typed context [no-untyped-call]
logger.append_keys(something="yes please")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Config
# pyproject.toml
[tool.mypy]
files = [ "**/*.py" ]
ignore_missing_imports = true
strict = true
pretty = true
show_error_codes = true
warn_unreachable = true
enable_error_code = [ "ignore-without-code", "redundant-expr", "truthy-bool" ]
plugins = [ "pydantic.mypy" ]
Run
I just run mypy
on the command line from within the virtual environment
Code snippet
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from aws_lambda_powertools import Logger
if TYPE_CHECKING:
from aws_lambda_powertools.utilities.typing import LambdaContext
logger = Logger(utc=True)
def lambda_handler(event: dict[str, Any], context: LambdaContext) -> dict[str, Any]:
logger.append_keys(something="yes please") # Error here
return {"hello": "world"}
Possible Solution
It seems that in a few places in powertools where a function or method would return None
, the return type annotation is omitted. One such example is append_keys
def append_keys(self, **additional_keys): |
The solution would be to simply add -> None:
as the return type annotation 🙂, preferably in other places where it's missing too.
Happy to do a PR for this, just waiting for triage 👍🏻
carlweise-chetwood and Jarbton
Metadata
Metadata
Assignees
Labels
loggertypingStatic typing definition related issues (mypy, pyright, etc.)Static typing definition related issues (mypy, pyright, etc.)
Type
Projects
Status
Shipped