chore(types): fix mapvalue and init #1271
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important
Add
floattoMapValuetype and improve initialization handling in Langfuse.floattoMapValueinmap_value.pyto support optional float values.Noneexplicitly inget_current_trace_id()andget_current_observation_id()inclient.pywhen tracing is disabled.# noqacomments in__init__.pyfor cleaner imports.This description was created by
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:
MapValue type expansion (
map_value.py): Addstyping.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.Import organization and explicit returns (
client.py): Reorders OpenTelemetry import statements for consistency and fixes two methods (get_current_trace_idandget_current_observation_id) to explicitly returnNoneinstead of using barereturnstatements. These methods haveOptional[str]return type annotations, so the explicitNonereturns ensure compliance with the declared types.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., inresource_manager.pyfor 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