Skip to content

mypy type errors after upgrading tenacity to 9.1.3: logging.Logger rejected #554

Closed

Description

@anpr

After upgrading Tenacity, mypy reports errors like:

error: Argument 1 to "before_sleep_log" has incompatible type "Logger"; expected "LoggerProtocol"  [arg-type]

I'm using the normal Python logging logger.
This should already reproduce the error:

  import logging
  from tenacity.before_sleep import before_sleep_log

  log = logging.getLogger(__name__)
  before_sleep_log(log, logging.INFO)  # mypy arg-type error

Activity

  1. maykcaldas commented on Feb 10, 2026

    @maykcaldas

    +1

  2. jd commented on Feb 10, 2026

    @jd
    Owner

    What about 9.1.4?

  3. omikader commented on Feb 11, 2026

    @omikader

    Hello @jd -- confirming that I am seeing this error on 9.1.4

    Argument 1 to "before_sleep_log" has incompatible type "Logger"; expected "LoggerProtocol"Mypy[arg-type](https://mypy.readthedocs.io/en/latest/_refs.html#code-arg-type)
    
    Following member(s) of "Logger" have conflicts:
        Expected:
            def log(self, int, str, /, *args: Any, **kwargs: Any) -> Any
        Got:
            def log(self, level: int, msg: object, *args: object, exc_info: bool | tuple[type[BaseException], BaseException, TracebackType | None] | tuple[None, None, None] | BaseException | None = ..., stack_info: bool = ..., stacklevel: int = ..., extra: Mapping[str, object] | None = ...) -> None
    

    Same repro as @anpr

  4. added a commit that references this issue on Feb 19, 2026
    bb33a08
  5. added a commit that references this issue on Feb 19, 2026
    773f438
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions