refactor: add generic type parameters for improved type flexibility#91
Open
tharropoulos wants to merge 6 commits intotypesense:masterfrom
Open
refactor: add generic type parameters for improved type flexibility#91tharropoulos wants to merge 6 commits intotypesense:masterfrom
tharropoulos wants to merge 6 commits intotypesense:masterfrom
Conversation
- Add `_CreateFieldT` and `_UpdateFieldT` type variables for field type constraints - Make `CollectionCreateSchema` generic with `_CreateFieldT` parameter - Make `CollectionSchema` inherit generic parameter from `CollectionCreateSchema` - Make `CollectionUpdateSchema` generic with `_UpdateFieldT` parameter - Add `CollectionSchemaCompat` and `CollectionUpdateSchemaCompat` type aliases for backward compatibility - Replace hardcoded union types with generic type parameters in field definitions
- Add `_DocumentImportParamsT` type variable for document import parameter constraints - Add `_ImportResponseT` type variable for import response type constraints - Add `_StringOrListT` type variable for string or list type constraints - Add `DocumentImportParametersGeneric` type variable for document import parameters - Define bounded type variables to improve type safety and flexibility
- Add `_ActionT` type variable for api key action type constraints - Make `ApiKeyCreateSchema` generic with `_ActionT` parameter - Make `ApiKeyCreateResponseSchema` inherit generic parameter from `ApiKeyCreateSchema` - Make `ApiKeySchema` and `ApiKeyRetrieveSchema` generic with `_ActionT` parameter - Add compatibility type aliases for backward compatibility - Replace hardcoded `_Actions` union type with generic `_ActionT` parameter
- Add `_OverrideRuleT` type variable for override rule type constraints - Make `OverrideCreateSchema` generic with `_OverrideRuleT` parameter - Make `OverrideSchema` inherit generic parameter from `OverrideCreateSchema` - Add `OverrideCreateSchemaCompat` and `OverrideSchemaCompat` type aliases for backward compatibility - Replace hardcoded union type with generic `_OverrideRuleT` parameter in rule field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TLDR
Added generic type parameters to API key, override, and document schemas for better type flexibility.
Change Summary
Code Changes:
In
src/typesense/types/key.py:_ActionTtype variable with bounds for API key action type constraintsApiKeyCreateSchema,ApiKeyCreateResponseSchema,ApiKeySchema, andApiKeyRetrieveSchemageneric with_ActionTparameterApiKeyCreateSchemaCompat,ApiKeySchemaCompat, etc.)_Actionsunion type with generic_ActionTparameter in actions fieldIn
src/typesense/types/override.py:_OverrideRuleTtype variable for override rule type constraintsOverrideCreateSchemaandOverrideSchemageneric with_OverrideRuleTparameterOverrideCreateSchemaCompat,OverrideSchemaCompat)In
src/typesense/types/document.py:_DocumentImportParamsT,_ImportResponseT, and_StringOrListTtype variablesDocumentImportParametersGenerictype variable for document import parametersIn
src/typesense/__init__.py:1.2.0to1.2.1Context
#90
PR Checklist