Skip to content

Commit 5604b22

Browse files
authored
Removed JSONType for Pydantic's equivalent JsonValue (#1022)
1 parent ea0d4ee commit 5604b22

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

paperqa/agents/models.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,18 @@
55
import time
66
from contextlib import asynccontextmanager
77
from enum import StrEnum
8-
from typing import Any, ClassVar, Protocol, TypeAlias, cast
8+
from typing import Any, ClassVar, Protocol, cast
99
from uuid import UUID, uuid4
1010

1111
from aviary.core import Message
1212
from lmi import LiteLLMModel, LLMModel
13-
from pydantic import (
14-
BaseModel,
15-
ConfigDict,
16-
Field,
17-
ValidationInfo,
18-
field_validator,
19-
)
13+
from pydantic import BaseModel, ConfigDict, Field, ValidationInfo, field_validator
2014

2115
from paperqa.types import PQASession
2216
from paperqa.version import __version__
2317

2418
logger = logging.getLogger(__name__)
2519

26-
JSONType: TypeAlias = (
27-
dict[str, "JSONType"] | list["JSONType"] | str | int | float | bool | None
28-
)
29-
3020

3121
class SupportsPickle(Protocol):
3222
"""Type protocol for typing any object that supports pickling."""

paperqa/agents/search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from typing import TYPE_CHECKING, Any, ClassVar
1818

1919
import anyio
20-
from pydantic import BaseModel
20+
from pydantic import BaseModel, JsonValue
2121
from rich.progress import (
2222
BarColumn,
2323
MofNCompleteColumn,
@@ -47,7 +47,7 @@
4747
from paperqa.types import VAR_MATCH_LOOKUP, DocDetails
4848
from paperqa.utils import ImpossibleParsingError, clean_possessives, hexdigest
4949

50-
from .models import JSONType, SupportsPickle
50+
from .models import SupportsPickle
5151

5252
if TYPE_CHECKING:
5353
from tantivy import IndexWriter
@@ -86,7 +86,7 @@ def write_to_string(self, data: BaseModel | SupportsPickle) -> bytes:
8686

8787
def read_from_string(
8888
self, data: str | bytes
89-
) -> BaseModel | SupportsPickle | JSONType:
89+
) -> BaseModel | SupportsPickle | JsonValue:
9090
if self == SearchDocumentStorage.JSON_MODEL_DUMP:
9191
return json.loads(data)
9292
if self == SearchDocumentStorage.PICKLE_COMPRESSED:

0 commit comments

Comments
 (0)