dd-trace-py
dd-trace-py copied to clipboard
[BUG]: tracer.wrap overrides the type of the decorated function
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 https://github.com/DataDog/dd-trace-py/pull/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