Skip to content

[BUG]: tracer.wrap overrides the type of the decorated function #13637

Open
@k4nar

Description

@k4nar

Tracer Version(s)

3.9.0, 3.9.1

Python Version(s)

Python 3.13.3

Pip Version(s)

N/A

Bug Report

Since ddtrace 3.9.0, the decorator @tracer.wrap() overrides the signature of the decorated function. Type checkers think it returns Any.

I believe this is a regression from #13480.

Reproduction Code

from typing import reveal_type

from ddtrace import tracer


@tracer.wrap()
def foo() -> int:
    return 42

reveal_type(foo())

Error Logs

$ uv run --with "ddtrace==3.9.1,mypy" mypy ddtrace-typing.py
ddtrace-typing.py:10: note: Revealed type is "Any"
Success: no issues found in 1 source file

$ uv run --with "ddtrace==3.8.0,mypy" mypy ddtrace-typing.py
ddtrace-typing.py:10: note: Revealed type is "builtins.int"
Success: no issues found in 1 source file

Libraries in Use

No response

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions