Skip to content

Conversation

@dinmukhamedm
Copy link
Member

@dinmukhamedm dinmukhamedm commented Nov 5, 2025

Fix and speed up mypy type reviews on the observed functions


Note

Tightens typing for observe decorators (sync/async) using generics and overloads, and bumps dev dependency litellm to >=1.79.1.

  • SDK decorators (src/lmnr/sdk/decorators.py):
    • Add precise type overloads for observe to support sync and async callables (Coroutine), refining decorator return types.
    • Use ParamSpec/TypeVar and update input_formatter/output_formatter to Callable[..., str].
    • Simplify async/sync branching; remove unnecessary casting.
  • OpenTelemetry decorators (src/lmnr/opentelemetry_lib/decorators/__init__.py):
    • Introduce TypeVar F bound to Callable[..., Any] and annotate decorator factories to return Callable[[F], F].
    • Align formatter annotations to Callable[..., str].
  • Dev dependencies (pyproject.toml):
    • Bump litellm in [dependency-groups].dev from >=1.77.0 to >=1.79.1.

Written by Cursor Bugbot for commit bf54efd. This will update automatically on new commits. Configure here.


Important

Improve decorator typing and update litellm dev dependency version.

  • Typing Improvements:
    • Add TypeVar F in __init__.py for better type safety in decorators.
    • Add overloads for observe() in decorators.py to handle sync and async functions separately.
    • Update return types in observe_base() and async_observe_base() in __init__.py to Callable[[F], F].
  • Dependency Update:
    • Bump litellm version from 1.77.0 to 1.79.1 in pyproject.toml.

This description was created by Ellipsis for bf54efd. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to bf54efd in 1 minute and 30 seconds. Click for details.
  • Reviewed 198 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. pyproject.toml:135
  • Draft comment:
    Bump dev dependency 'litellm' to 1.79.1. Ensure that any breaking changes in this version have been validated against our codebase.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is about a dependency change, specifically bumping a dev dependency version. The comment asks to ensure that any breaking changes have been validated, which falls under the rule of not asking the PR author to ensure behavior is intended or tested. Therefore, this comment should be removed.
2. src/lmnr/opentelemetry_lib/decorators/__init__.py:5
  • Draft comment:
    Importing 'TypeVar' and defining generic 'F' improves type safety for decorator wrappers.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative and does not provide any actionable feedback or suggestions for improvement. It simply states that importing TypeVar and defining a generic F improves type safety, which is not aligned with the rules for useful comments.
3. src/lmnr/opentelemetry_lib/decorators/__init__.py:184
  • Draft comment:
    The updated return type for observe_base (Callable[[F], F]) ensures the decorator preserves the wrapped function's signature. This is a good improvement for static type checking.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, praising the change without suggesting any improvements or asking for clarifications. It doesn't align with the rules as it doesn't provide actionable feedback or raise any concerns.
4. src/lmnr/sdk/decorators.py:23
  • Draft comment:
    Overloaded signatures for observe now clearly differentiate between synchronous and asynchronous functions with flexible formatter types. This clarity improves type checking with mypy.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, praising the changes made to the code. It does not provide any actionable feedback or suggestions for improvement. According to the rules, purely informative comments should be removed.
5. src/lmnr/sdk/decorators.py:175
  • Draft comment:
    The use of the 'is_async' check to choose between async and sync decorator bases is neat. Ensure that the 'is_async' implementation reliably detects asynchronous functions.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the author to ensure that the is_async implementation reliably detects asynchronous functions. This is a general request for confirmation and does not provide a specific suggestion or point out a specific issue. It violates the rule against asking the author to ensure behavior is intended.
6. src/lmnr/opentelemetry_lib/decorators/__init__.py:301
  • Draft comment:
    In the async exception handler, prefer using 'raise' (without an argument) instead of 'raise e' to preserve the original traceback context.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. src/lmnr/sdk/decorators.py:5
  • Draft comment:
    Typographical issue: The content on line 5 appears to be just ")" which seems out of place. Please check if this is a stray character or formatting error meant to be removed.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_77RKU4sMFF8Ycb6i

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@dinmukhamedm dinmukhamedm merged commit 0a7026c into main Nov 5, 2025
7 checks passed
@dinmukhamedm dinmukhamedm deleted the mypy branch November 5, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants