Improve IDE Tab-Completion and Type Hinting Support #549
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.
Improve IDE Tab-Completion and Type Hinting Support
Summary
This PR enhances IDE tab-completion and type hinting support for the Pinecone Python SDK by ensuring complete type coverage. It adds missing return type annotations, class-level attribute type annotations, completes the type stub file, and ensures the
py.typedmarker file is included in package distribution.Problem
Some areas of the codebase lacked complete type annotations, which limited IDE tab-completion and type checking capabilities:
UpsertResponseTransformer.get(),__getattr__())__init__.pyistub file was incomplete, missing several exported types including deprecated functions, theAdminclass,__version__, and various lazy-loaded typespy.typedmarker file wasn't explicitly configured in the build system, potentially causing issues with type checker discoverySolution
Enhanced IDE support and type checking by:
py.typedmarker file is included: Added explicit configuration inpyproject.tomlto guarantee the PEP 561 marker file is packagedUpsertResponseTransformer.get()(returnsUpsertResponse) and__getattr__()(returnsAny)PluginAware._plugins_loadedUpsertResponseTransformer._apply_resultIndexclass attributes (_config,_openapi_config,_pool_threads,_vector_api,_api_client)IndexAsyncioclass attributes (config,_openapi_config,_vector_api,_api_client)__init__.pyistub file: Added all missing exported types including:Adminclass__version__Optional[str]withstr | Noneinvector_grpc.pyfor consistencyUser-Facing Impact
Benefits
Breaking Changes
None - This is a purely additive change. All existing code continues to work without modification.
Migration Guide
No migration required for users. The changes are internal to the SDK and transparent to users. Users will automatically benefit from improved IDE support when they update to this version.
Example Usage
The improvements are transparent to users, but developers will notice better IDE support:
Technical Details
Type Stub File Completion
The
__init__.pyistub file now includes all exports from__init__.py, ensuring type checkers and IDEs have complete information about what's available in the package. This includes:Class-Level Attribute Annotations
Adding class-level type annotations for instance attributes (PEP 526) allows IDEs to:
PEP 561 Compliance
Explicitly including
py.typedin the package distribution ensures type checkers can discover that the package contains type information, following PEP 561 guidelines.Testing
py.typedis included in package distribution__init__.pyistub file matches all exports from__init__.pyCompatibility