fix: avoid private import of Langfuse to satisify Pyright #1275
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.
Fixes langfuse/langfuse#8176
Pyright flags Langfuse import as private after py.typed was added.
Fix: explicitly re-export in init.py
Important
Re-export
Langfuse
in__init__.py
to avoid Pyright flagging it as a private import.Langfuse
in__init__.py
to avoid Pyright flagging it as a private import.py.typed
.This description was created by
for 8c91957. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Summary
This PR addresses a type checking issue with Pyright that arose after the package was marked as typed with
py.typed
. The change modifies how theLangfuse
class is imported and re-exported in the package's__init__.py
file.What changed:
Langfuse
from the private module._client.client
, the code now imports the entireclient
module as_client
Langfuse
class is then re-exported through an explicit attribute assignment:Langfuse = _client.Langfuse
Why this change was needed:
Pyright enforces that modules prefixed with underscores (like
._client.client
) are private and should not be directly imported from outside the package. Whenpy.typed
was added to mark the package as typed, Pyright began flagging the direct import as accessing private internals.How it fits with the codebase:
This change maintains the exact same public API - users can still import
Langfuse
from the package root as before. The__all__
list remains unchanged, ensuring the public interface is preserved. This is a common Python pattern for controlling what gets exposed as the public interface while keeping internal module structure private. The change only affects the import mechanism, not the functionality or runtime behavior.Confidence score: 5/5