Skip to content

Typing: Getting type errors on logger usage #3171

Closed
@mew1033

Description

@mew1033

Expected Behaviour

We should be able to use logger.info("log message: %s", "text") without type errors.

Current Behaviour

Currently, when logging with the powertools logger, I get the following type error in pylance/pyright:

Type of "info" is partially unknown
  Type of "info" is "(msg: object, *args: Unknown, exc_info: Unknown | None = None, stack_info: bool = False, stacklevel: int = 2, extra: Mapping[str, object] | None = None, **kwargs: Unknown) -> None"Pylance[reportUnknownMemberType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUnknownMemberType)

Code snippet

from aws_lambda_powertools.logging import Logger

logger = Logger()
logger.info("logging logs %s", "text")

Possible Solution

No response

Steps to Reproduce

Any of the logging level functions issues the same error.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.11

Packaging format used

PyPi

Debugging logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-upstreamSomething isn't working in an upstream dependencyhelp wantedCould use a second pair of eyes/handsloggertypingStatic 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