-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced ModelInstance type with rdfproxy.utils._types._TMOdelInstance. ModelInstance was defined using PEP 695 before but the type will be used all over the code base and should have a central definition. Fixed _TModelConstructorCallable type to be a Callable expecting a SPARQLWrapper.QueryResult parameter and returning an Iterable of Pydantic model instances. closes: #10
- Loading branch information
Showing
2 changed files
with
18 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
"""Type definitions for rdfproxy.""" | ||
|
||
from collections.abc import Iterable | ||
from typing import Annotated, Protocol, TypeVar, runtime_checkable | ||
|
||
from SPARQLWrapper import QueryResult | ||
from pydantic import BaseModel | ||
|
||
|
||
_TModelInstance: Annotated[TypeVar, "Type defintion for Pydantic model instances."] = ( | ||
TypeVar("_TModelInstance", bound=BaseModel) | ||
) | ||
_TModelInstance = TypeVar("_TModelInstance", bound=BaseModel) | ||
|
||
|
||
@runtime_checkable | ||
class _TModelConstructorCallable[ModelType: BaseModel](Protocol): | ||
"""Callback protocol for model constructor callables.""" | ||
|
||
def __call__(self, **kwargs) -> ModelType: ... | ||
def __call__(self, query_result: QueryResult) -> Iterable[ModelType]: ... |