GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: add generic type parameters for improved type flexibility by tharropoulos · Pull Request #91 · typesense/typesense-python

Conversation

@tharropoulos

@tharropoulos tharropoulos commented Jun 18, 2025

Copy link
Copy Markdown
Collaborator

TLDR

Added generic type parameters to API key, override, and document schemas for better type flexibility.

Change Summary

Code Changes:

  1. In src/typesense/types/key.py:

    • Added _ActionT type variable with bounds for API key action type constraints
    • Made ApiKeyCreateSchema, ApiKeyCreateResponseSchema, ApiKeySchema, and ApiKeyRetrieveSchema generic with _ActionT parameter
    • Added backward compatibility aliases (ApiKeyCreateSchemaCompat, ApiKeySchemaCompat, etc.)
    • Replaced hardcoded _Actions union type with generic _ActionT parameter in actions field
  2. In src/typesense/types/override.py:

    • Added _OverrideRuleT type variable for override rule type constraints
    • Made OverrideCreateSchema and OverrideSchema generic with _OverrideRuleT parameter
    • Added compatibility type aliases (OverrideCreateSchemaCompat, OverrideSchemaCompat)
    • Replaced hardcoded union type with generic parameter in rule field
  3. In src/typesense/types/document.py:

    • Added _DocumentImportParamsT, _ImportResponseT, and _StringOrListT type variables
    • Added DocumentImportParametersGeneric type variable for document import parameters
    • Defined bounded type variables to improve type safety and flexibility
  4. In src/typesense/__init__.py:

    • Bumped version from 1.2.0 to 1.2.1

Context

#90

PR Checklist

  • I have read and signed the Contributor License Agreement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tharropoulos added 6 commits June 18, 2025 10:26
@tharropoulos
refactor(types): add generic type parameters to collection schemas
590c086
- 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
@tharropoulos
refactor(types): add generic type variables for document operations
f4d6908
- 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
@tharropoulos
refactor(types): add generic type parameters to api key schemas
8b1cbd0
- 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
@tharropoulos
refactor(types): add generic type parameters to override schemas
d7338d0
- 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
@tharropoulos
chore: bump ver
60af1e8
@tharropoulos
fix(types): fix override generic type parameter for retrieve schema
8853e3f

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@tharropoulos
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.