Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Jul 24, 2025

Important

Add float to MapValue type and improve initialization handling in Langfuse.

  • Types:
    • Add float to MapValue in map_value.py to support optional float values.
  • Initialization:
    • Return None explicitly in get_current_trace_id() and get_current_observation_id() in client.py when tracing is disabled.
  • Misc:
    • Remove # noqa comments in __init__.py for cleaner imports.

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

Disclaimer: Experimental PR review

Greptile Summary

This PR fixes MyPy type checking issues across three files as part of improving static type analysis compliance. The changes include:

  1. MapValue type expansion (map_value.py): Adds typing.Optional[float] to the MapValue union type, expanding it from supporting string, int, bool, and list of strings to also include floating-point numbers. This change makes the type definition more comprehensive and accurate for API data that includes decimal values like scores, metrics, or pricing information.

  2. Import organization and explicit returns (client.py): Reorders OpenTelemetry import statements for consistency and fixes two methods (get_current_trace_id and get_current_observation_id) to explicitly return None instead of using bare return statements. These methods have Optional[str] return type annotations, so the explicit None returns ensure compliance with the declared types.

  3. Unused import cleanup (__init__.py): Removes the unused __version__ import and reorganizes remaining imports alphabetically. The version information is still available internally where needed (e.g., in resource_manager.py for SDK headers), but was never part of the public API since it wasn't in the __all__ list.

These changes integrate well with the existing codebase by maintaining backward compatibility while improving type safety. The MapValue type is used throughout the API commons module for representing various data values, so the float addition enhances type coverage without breaking existing functionality. The client fixes ensure proper typing for tracing utilities, and the init cleanup removes dead code while maintaining clean import organization.

Confidence score: 5/5

  • This PR is extremely safe to merge with virtually no risk of production issues.
  • All changes are backwards-compatible type fixes, import organization, and dead code removal that improve code quality without altering functionality.
  • No files need additional attention as the changes are straightforward and well-targeted.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@hassiebp hassiebp merged commit 8bd1533 into main Jul 24, 2025
10 checks passed
@hassiebp hassiebp deleted the fix-mypy-issues branch July 24, 2025 16:44
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.

2 participants