Skip to content

Commit

Permalink
fix: more pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanleomk committed Dec 18, 2024
1 parent 386ffe6 commit ddc4825
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions instructor/client_vertexai.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ def _create_vertexai_tool(models: Union[BaseModel, list[BaseModel], type]) -> gm
"""Creates a tool with function declarations for single model or list of models"""
# Handle Iterable case first
if get_origin(models) is not None:
model_list = list(get_types_array(models))
model_list = list(get_types_array(models)) # type: ignore
else:
# Handle both single model and list of models
model_list = models if isinstance(models, list) else [models]

declarations = []
for model in model_list:
parameters = _create_gemini_json_schema(model)
for model in model_list: # type: ignore
parameters = _create_gemini_json_schema(model) # type: ignore
declaration = gm.FunctionDeclaration(
name=model.__name__,
description=model.__doc__,
parameters=parameters
name=model.__name__, # type: ignore
description=model.__doc__, # type: ignore
parameters=parameters,
)
declarations.append(declaration)
declarations.append(declaration) # type: ignore

return gm.Tool(function_declarations=declarations)
return gm.Tool(function_declarations=declarations) # type: ignore


def vertexai_message_parser(
Expand Down Expand Up @@ -99,7 +99,9 @@ def vertexai_function_response_parser(
)


def vertexai_process_response(_kwargs: dict[str, Any], model: Union[BaseModel, list[BaseModel], type]): # noqa: UP007
def vertexai_process_response(
_kwargs: dict[str, Any], model: Union[BaseModel, list[BaseModel], type]

Check failure on line 103 in instructor/client_vertexai.py

View workflow job for this annotation

GitHub Actions / Ruff (ubuntu-latest)

Ruff (UP007)

instructor/client_vertexai.py:103:37: UP007 Use `X | Y` for type annotations
): # noqa: UP007
messages: list[dict[str, str]] = _kwargs.pop("messages")
contents = _vertexai_message_list_parser(messages) # type: ignore

Expand Down
4 changes: 2 additions & 2 deletions instructor/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async def new_create_async(

response_model, new_kwargs = handle_response_model(
response_model=response_model, mode=mode, **kwargs
)
) # type: ignore
new_kwargs = handle_templating(new_kwargs, context)

response = await retry_async(
Expand Down Expand Up @@ -186,7 +186,7 @@ def new_create_sync(

response_model, new_kwargs = handle_response_model(
response_model=response_model, mode=mode, **kwargs
)
) # type: ignore

new_kwargs = handle_templating(new_kwargs, context)

Expand Down

0 comments on commit ddc4825

Please sign in to comment.