Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to pydantic>2 #181

Closed
Tracked by #22
jgunstone opened this issue Aug 15, 2023 · 4 comments · Fixed by #199
Closed
Tracked by #22

update to pydantic>2 #181

jgunstone opened this issue Aug 15, 2023 · 4 comments · Fixed by #199

Comments

@jgunstone
Copy link
Collaborator

jgunstone commented Aug 15, 2023

https://docs.pydantic.dev/latest/migration/

@JuanCab
Copy link

JuanCab commented Aug 18, 2023

Are you open to a pull request that would fix this by using a try.. except.. block to handle the import? Something like:

try:
    import pydantic.v1 as pydantic
except ImportError:
    import pydantic as pydantic

This should in principle use the v1 API for BaseClass when using pydantic version 2 according to the documentation here.

@jgunstone
Copy link
Collaborator Author

hi there -

good point.

I actually pinned to old pydantic here:
75334be

the purpose of your suggestion would be to allow users of pydantic v2 still use old ipyautoui without dependency issues ?

I'm currently working on a new release that will require pydantic v2 (and will not be compatible with v1) and benefit from some of its new features

@JuanCab
Copy link

JuanCab commented Aug 22, 2023

I noticed it was pinned to pydantic<2 (I had to pin my own environment to avoid incompatibility), I just thought it might be a way to support newer pydantic installs if migrating pyautoui proved slow going.

@jgunstone
Copy link
Collaborator Author

I just tried implementing the try: except: block as @JuanCab suggests (as the update is indeed going slightly slower than I hoped... ) -

I'm running into the following issue:

import pydantic.v1 as pydantic

class Test(BaseModel):
    __root__: list[str] = ["a", "b"]

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

root models are used for the iterable and editgrid objects, reimplementing them as suggested above would then be incompatible with pydantic">1,<2" -

so I think we'll probably have to wait until the next major update which will use pydantic v2 rather than backporting to the v1 that is available in v2

@jgunstone jgunstone linked a pull request Oct 10, 2023 that will close this issue
@jgunstone jgunstone mentioned this issue Oct 10, 2023
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants