fix(python): correct type annotations in EmbeddingFunctionRegistry (#2478)

- Fix register() method's alias parameter type from 'str = None' to
'Optional[str] = None'
- Add return type annotation 'Type[EmbeddingFunction]' to get() method
- Import Type from typing module for proper type hints
This commit is contained in:
aniaan
2025-07-25 03:31:49 +08:00
committed by GitHub
parent b9e3c36d82
commit f45f0d0431

View File

@@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
import json
from typing import Dict, Optional
from typing import Dict, Optional, Type
from .base import EmbeddingFunction, EmbeddingFunctionConfig
@@ -43,7 +43,7 @@ class EmbeddingFunctionRegistry:
self._functions = {}
self._variables = {}
def register(self, alias: str = None):
def register(self, alias: Optional[str] = None):
"""
This creates a decorator that can be used to register
an EmbeddingFunction.
@@ -75,7 +75,7 @@ class EmbeddingFunctionRegistry:
"""
self._functions = {}
def get(self, name: str):
def get(self, name: str) -> Type[EmbeddingFunction]:
"""
Fetch an embedding function class by name