Closed jgunstone closed 11 months ago
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.
hi there -
good point.
I actually pinned to old pydantic here: 75334be11660b3ccd1d81a81d7854c7a3e40df57
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
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.
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
https://docs.pydantic.dev/latest/migration/