Skip to content

Commit

Permalink
fix: remove unnecessary type ignore comments
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] and jxnl committed Dec 15, 2024
1 parent a835030 commit 87a3876
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions instructor/batch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Union, TypeVar, Optional
from collections.abc import Iterable
from pydantic import BaseModel, Field # type: ignore
from pydantic import BaseModel, Field
from instructor.process_response import handle_response_model
import instructor
import uuid
Expand Down Expand Up @@ -137,7 +137,7 @@ def create_from_messages(
"temperature": temperature,
"messages": messages,
**kwargs,
}
},
}
file.write(json.dumps(request) + "\n")
else:
Expand Down
4 changes: 2 additions & 2 deletions instructor/dsl/citation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field, model_validator, ValidationInfo # type: ignore
from pydantic import BaseModel, Field, model_validator, ValidationInfo
from collections.abc import Generator


Expand Down Expand Up @@ -57,7 +57,7 @@ class User(BaseModel):
description="List of unique and specific substrings of the quote that was used to answer the question.",
)

@model_validator(mode="after") # type: ignore[misc]
@model_validator(mode="after")

Check failure on line 60 in instructor/dsl/citation.py

View workflow job for this annotation

GitHub Actions / Pyright (ubuntu-latest, 3.11)

Argument of type "(self: Self@CitationMixin, info: ValidationInfo) -> CitationMixin" cannot be assigned to parameter of type "_AnyModelAfterValidator[_ModelType@model_validator]"   Type "(self: Self@CitationMixin, info: ValidationInfo) -> CitationMixin" is incompatible with type "_AnyModelAfterValidator[_ModelType@model_validator]"     Type "(self: Self@CitationMixin, info: ValidationInfo) -> CitationMixin" is incompatible with type "ModelAfterValidator[_ModelType@model_validator]"       Parameter 1: type "_ModelType@model_validator" is incompatible with type "Self@CitationMixin"         Type "CitationMixin" is incompatible with type "Self@CitationMixin"     Type "(self: Self@CitationMixin, info: ValidationInfo) -> CitationMixin" is incompatible with type "ModelAfterValidatorWithoutInfo[_ModelType@model_validator]"       Parameter 1: type "_ModelType@model_validator" is incompatible with type "Self@CitationMixin"         Type "CitationMixin" is incompatible with type "Self@CitationMixin"       Extra parameter "info" (reportArgumentType)

Check failure on line 60 in instructor/dsl/citation.py

View workflow job for this annotation

GitHub Actions / Pyright (macos-latest, 3.11)

Argument of type "(self: Self@CitationMixin, info: ValidationInfo) -> CitationMixin" cannot be assigned to parameter of type "_AnyModelAfterValidator[_ModelType@model_validator]"   Type "(self: Self@CitationMixin, info: ValidationInfo) -> CitationMixin" is incompatible with type "_AnyModelAfterValidator[_ModelType@model_validator]"     Type "(self: Self@CitationMixin, info: ValidationInfo) -> CitationMixin" is incompatible with type "ModelAfterValidator[_ModelType@model_validator]"       Parameter 1: type "_ModelType@model_validator" is incompatible with type "Self@CitationMixin"         Type "CitationMixin" is incompatible with type "Self@CitationMixin"     Type "(self: Self@CitationMixin, info: ValidationInfo) -> CitationMixin" is incompatible with type "ModelAfterValidatorWithoutInfo[_ModelType@model_validator]"       Parameter 1: type "_ModelType@model_validator" is incompatible with type "Self@CitationMixin"         Type "CitationMixin" is incompatible with type "Self@CitationMixin"       Extra parameter "info" (reportArgumentType)
def validate_sources(self, info: ValidationInfo) -> "CitationMixin":
"""
For each substring_phrase, find the span of the substring_phrase in the context.
Expand Down
16 changes: 13 additions & 3 deletions instructor/dsl/iterable.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Optional, cast, ClassVar
from collections.abc import AsyncGenerator, Generator, Iterable

from pydantic import BaseModel, Field, create_model # type: ignore
from pydantic import BaseModel, Field, create_model

from instructor.function_calls import OpenAISchema
from instructor.mode import Mode
Expand Down Expand Up @@ -109,7 +109,12 @@ def extract_json(
}:
if json_chunk := chunk.choices[0].delta.content:
yield json_chunk
elif mode in {Mode.TOOLS, Mode.TOOLS_STRICT, Mode.FIREWORKS_TOOLS, Mode.WRITER_TOOLS}:
elif mode in {
Mode.TOOLS,
Mode.TOOLS_STRICT,
Mode.FIREWORKS_TOOLS,
Mode.WRITER_TOOLS,
}:
if json_chunk := chunk.choices[0].delta.tool_calls:
if json_chunk[0].function.arguments is not None:
yield json_chunk[0].function.arguments
Expand Down Expand Up @@ -145,7 +150,12 @@ async def extract_json_async(
}:
if json_chunk := chunk.choices[0].delta.content:
yield json_chunk
elif mode in {Mode.TOOLS, Mode.TOOLS_STRICT, Mode.FIREWORKS_TOOLS, Mode.WRITER_TOOLS}:
elif mode in {
Mode.TOOLS,
Mode.TOOLS_STRICT,
Mode.FIREWORKS_TOOLS,
Mode.WRITER_TOOLS,
}:
if json_chunk := chunk.choices[0].delta.tool_calls:
if json_chunk[0].function.arguments is not None:
yield json_chunk[0].function.arguments
Expand Down
2 changes: 1 addition & 1 deletion instructor/dsl/maybe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field, create_model # type: ignore
from pydantic import BaseModel, Field, create_model
from typing import Generic, Optional, TypeVar

T = TypeVar("T", bound=BaseModel)
Expand Down
2 changes: 1 addition & 1 deletion instructor/dsl/validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Callable, Optional

from openai import OpenAI
from pydantic import Field # type: ignore
from pydantic import Field

from instructor.function_calls import OpenAISchema
from instructor.client import Instructor
Expand Down

0 comments on commit 87a3876

Please sign in to comment.