[PR #32163] refactor(api): tighten OTel decorator typing #33585

Closed
opened 2026-02-21 20:53:33 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/32163

State: closed
Merged: Yes


Context
This continues issue #25063 by removing Any from OTel decorator wrapper signatures while preserving runtime behavior and callable signatures.

What changed

  • Preserve wrapped function signatures in trace_span using ParamSpec.
  • Use concrete args/kwargs container types in SpanHandler and AppGenerateHandler to avoid invalid ParamSpec usage in non-variadic parameters.

Why
This eliminates Any in key typing hotspots without affecting behavior, and keeps the decorator contract precise and stable.

Issue
Fixes #25063

Checks run

  • uv run --project api make lint
  • uv run --project api make type-check
  • uv run --project api make test
**Original Pull Request:** https://github.com/langgenius/dify/pull/32163 **State:** closed **Merged:** Yes --- Context This continues issue #25063 by removing Any from OTel decorator wrapper signatures while preserving runtime behavior and callable signatures. What changed - Preserve wrapped function signatures in trace_span using ParamSpec. - Use concrete args/kwargs container types in SpanHandler and AppGenerateHandler to avoid invalid ParamSpec usage in non-variadic parameters. Why This eliminates Any in key typing hotspots without affecting behavior, and keeps the decorator contract precise and stable. Issue Fixes #25063 Checks run - uv run --project api make lint - uv run --project api make type-check - uv run --project api make test
yindo added the pull-request label 2026-02-21 20:53:33 -05:00
yindo closed this issue 2026-02-21 20:53:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33585