OpenXbox / xbox-webapi-python

A python library to authenticate with Xbox Live via your Microsoft Account and provides Xbox related Web-API.
https://pypi.python.org/pypi/xbox-webapi
MIT License
175 stars 44 forks source link

TypeError: To define root models, use `pydantic.RootModel` rather than a field called '__root__' #98

Closed vertyco closed 7 months ago

vertyco commented 9 months ago

We need compatibility with the latest pydantic version

  File "/mnt/nas/reclaimer/Projects/PrivateCogs/arktools/arktools.py", line 51, in <module>
    from xbox.webapi.api.client import XboxLiveClient
  File "/home/vert/.local/share/Red-DiscordBot/data/autto/cogs/Downloader/lib/xbox/webapi/api/client.py", line 23, in <module>
    from xbox.webapi.api.provider.presence import PresenceProvider
  File "/home/vert/.local/share/Red-DiscordBot/data/autto/cogs/Downloader/lib/xbox/webapi/api/provider/presence/__init__.py", line 7, in <module>
    from xbox.webapi.api.provider.presence.models import (
  File "/home/vert/.local/share/Red-DiscordBot/data/autto/cogs/Downloader/lib/xbox/webapi/api/provider/presence/models.py", line 27, in <module>
    class PresenceBatchResponse(CamelCaseModel):
  File "/home/vert/redenv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 104, in __new__
    private_attributes = inspect_namespace(
                         ^^^^^^^^^^^^^^^^^^
  File "/home/vert/redenv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 314, in inspect_namespace
    raise TypeError("To define root models, use `pydantic.RootModel` rather than a field called '__root__'")
TypeError: To define root models, use `pydantic.RootModel` rather than a field called '__root__'
codilau commented 8 months ago

Hi, any chance of this issue getting fixed? Did you find a solution @vertyco ?

vertyco commented 8 months ago

@codilau there is a good bit that will need to be changed for pydantic >2.x.x unfortunately. in addition to not being able to name atributes __root__, the way you overwrite the model config has changed, and the order in which aliases are generated have also changed, so the entire model structure will need to be looked at.

pikulo-kama commented 8 months ago

Hi, are there any updates on this one?

tuxuser commented 7 months ago

Fixed with v2.1.0