Skip to content

Commit

Permalink
Temporarily fix pydantic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thesadru authored Jul 5, 2023
1 parent a6c003b commit a261c2b
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 38 deletions.
4 changes: 2 additions & 2 deletions genshin/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ async def genshin_notes(client: genshin.Client, uid: typing.Optional[int]) -> No
for expedition in data.expeditions:
if expedition.remaining_time > datetime.timedelta(0):
remaining = f"{expedition.remaining_time} remaining"
click.echo(f" - {expedition.status} | {remaining} - {expedition.character.name}")
click.echo(f" - {expedition.status} | {remaining}")
else:
click.echo(f" - {expedition.status} | {expedition.character.name}")
click.echo(f" - {expedition.status}")


@cli.command()
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import collections
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.model import Aliased, APIModel, Unique

Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.model import APIModel, Unique

Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/chronicle/abyss.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.genshin import character
from genshin.models.model import Aliased, APIModel
Expand Down
6 changes: 3 additions & 3 deletions genshin/models/genshin/chronicle/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import re
import typing

import pydantic
import pydantic.generics
import pydantic.v1 as pydantic
import pydantic.v1.generics as pydantic_generics

from genshin.models.genshin import character
from genshin.models.model import Aliased, APIModel
Expand All @@ -23,7 +23,7 @@
ModelT = typing.TypeVar("ModelT", bound=APIModel)


class OldActivity(APIModel, pydantic.generics.GenericModel, typing.Generic[ModelT]):
class OldActivity(APIModel, pydantic_generics.GenericModel, typing.Generic[ModelT]):
"""Arbitrary activity for chinese events."""

# sometimes __parameters__ may not be provided in older versions
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/chronicle/characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.genshin import character
from genshin.models.model import Aliased, APIModel, Unique
Expand Down
18 changes: 3 additions & 15 deletions genshin/models/genshin/chronicle/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import datetime
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.genshin import character
from genshin.models.model import Aliased, APIModel

__all__ = ["Expedition", "ExpeditionCharacter", "Notes"]
__all__ = ["Expedition", "Notes"]


def _process_timedelta(time: typing.Union[int, datetime.timedelta, datetime.datetime]) -> datetime.datetime:
Expand All @@ -26,14 +25,10 @@ def _process_timedelta(time: typing.Union[int, datetime.timedelta, datetime.date
return time


class ExpeditionCharacter(character.BaseCharacter):
"""Expedition character."""


class Expedition(APIModel):
"""Real-Time note expedition."""

character: ExpeditionCharacter = Aliased("avatar_side_icon")
character_icon: str = Aliased("avatar_side_icon")
status: typing.Literal["Ongoing", "Finished"]
remaining_time: datetime.timedelta = Aliased("remained_time")

Expand All @@ -46,13 +41,6 @@ def finished(self) -> bool:
def completion_time(self) -> datetime.datetime:
return datetime.datetime.now().astimezone() + self.remaining_time

@pydantic.validator("character", pre=True)
def __complete_character(cls, v: typing.Any) -> typing.Any:
if isinstance(v, str):
return dict(icon=v) # type: ignore

return v


class TransformerTimedelta(datetime.timedelta):
"""Transformer recovery time."""
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/chronicle/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models import hoyolab
from genshin.models.model import Aliased, APIModel
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/chronicle/tcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import enum
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.model import Aliased, APIModel, Unique

Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/gacha.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.model import Aliased, APIModel, Unique

Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/lineup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import datetime
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.genshin import character
from genshin.models.model import Aliased, APIModel, Unique
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/teapot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import datetime
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.model import Aliased, APIModel, Unique

Expand Down
2 changes: 1 addition & 1 deletion genshin/models/genshin/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import typing
import unicodedata

import pydantic
import pydantic.v1 as pydantic

from genshin.models.model import Aliased, APIModel, Unique

Expand Down
2 changes: 1 addition & 1 deletion genshin/models/honkai/battlesuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.model import Aliased, APIModel, Unique

Expand Down
2 changes: 1 addition & 1 deletion genshin/models/honkai/chronicle/battlesuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.honkai import battlesuit
from genshin.models.model import Aliased, APIModel, Unique
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/honkai/chronicle/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models.honkai import battlesuit
from genshin.models.model import Aliased, APIModel, Unique
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/honkai/chronicle/stats.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Honkai stats models."""
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin.models import hoyolab
from genshin.models.model import Aliased, APIModel
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/hoyolab/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
import typing

import pydantic
import pydantic.v1 as pydantic

from genshin import types
from genshin.models.model import Aliased, APIModel, Unique
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import types
import typing

import pydantic
import pydantic.v1 as pydantic

import genshin.constants as genshin_constants

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
aiohttp
pydantic
pydantic==2.*

# subdependencies
yarl
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
packages=find_packages(exclude=["tests.*"]),
python_requires=">=3.8",
install_requires=["aiohttp", "pydantic"],
install_requires=["aiohttp", "pydantic==2.*"],
extras_require={
"all": ["browser-cookie3", "rsa", "click"],
"cookies": ["browser-cookie3"],
Expand Down

0 comments on commit a261c2b

Please sign in to comment.