mirror of
https://github.com/miaowware/qrm2.git
synced 2024-11-21 23:45:16 -05:00
bump pydantic to version 2
This commit is contained in:
parent
f8d7316071
commit
ce99cc194e
@ -6,4 +6,4 @@ beautifulsoup4
|
|||||||
pytz
|
pytz
|
||||||
cairosvg
|
cairosvg
|
||||||
httpx
|
httpx
|
||||||
pydantic
|
pydantic~=2.5
|
||||||
|
@ -23,7 +23,7 @@ class ResourcesManager:
|
|||||||
|
|
||||||
def parse_index(self, index: str):
|
def parse_index(self, index: str):
|
||||||
"""Parses the index."""
|
"""Parses the index."""
|
||||||
return Index.parse_raw(index)
|
return Index.model_validate_json(index)
|
||||||
|
|
||||||
def sync_fetch(self, filepath: str):
|
def sync_fetch(self, filepath: str):
|
||||||
"""Fetches files in sync mode."""
|
"""Fetches files in sync mode."""
|
||||||
|
@ -10,7 +10,7 @@ SPDX-License-Identifier: LiLiQ-Rplus-1.1
|
|||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, RootModel
|
||||||
|
|
||||||
|
|
||||||
class File(BaseModel):
|
class File(BaseModel):
|
||||||
@ -22,18 +22,17 @@ class File(BaseModel):
|
|||||||
return repr(self)
|
return repr(self)
|
||||||
|
|
||||||
|
|
||||||
class Resource(BaseModel, Mapping):
|
class Resource(RootModel, Mapping):
|
||||||
# 'A Beautiful Hack' https://github.com/samuelcolvin/pydantic/issues/1802
|
root: dict[str, list[File]]
|
||||||
__root__: dict[str, list[File]]
|
|
||||||
|
|
||||||
def __getitem__(self, key: str) -> list[File]:
|
def __getitem__(self, key: str) -> list[File]:
|
||||||
return self.__root__[key]
|
return self.root[key]
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.__root__)
|
return iter(self.root)
|
||||||
|
|
||||||
def __len__(self) -> int:
|
def __len__(self) -> int:
|
||||||
return len(self.__root__)
|
return len(self.root)
|
||||||
|
|
||||||
# For some reason those were not the same???
|
# For some reason those were not the same???
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
@ -41,7 +40,7 @@ class Resource(BaseModel, Mapping):
|
|||||||
|
|
||||||
# Make the repr more logical (despite the technical inaccuracy)
|
# Make the repr more logical (despite the technical inaccuracy)
|
||||||
def __repr_args__(self):
|
def __repr_args__(self):
|
||||||
return self.__root__.items()
|
return self.root.items()
|
||||||
|
|
||||||
|
|
||||||
class Index(BaseModel, Mapping):
|
class Index(BaseModel, Mapping):
|
||||||
|
Loading…
Reference in New Issue
Block a user