pydantic-cli icon indicating copy to clipboard operation
pydantic-cli copied to clipboard

Compatibility to pydantic >= 2

Open bolau opened this issue 1 year ago • 6 comments

Hi, I use fastapi and pydantic-cli in the same project. I would like to use pydantic in a recent version, but pydantic-cli restricts it to <2 in the requirements.txt. Do you plan to accomodate the newer versions at some point? Best, Boris

bolau avatar Dec 22 '23 15:12 bolau

Hi!

I'd like to second this ask. It looks like there is something in #54 by the dependabot, though it appears to have failed CI and nothing was done after (It makes sense that this would fail, pydantic 2 has many breaking changes). I was looking at this tool as it would do what I want typer to do (to turn pydantic models into flags). Is there any way I could help @mpkocher?

Best, Adrian

acederberg avatar Jan 03 '24 19:01 acederberg

I'll look into supporting Pydantic 2.

What is the minimum version of 2 (>= 2.5.x?) that should be supported?

mpkocher avatar Jan 08 '24 22:01 mpkocher

@mpkocher 2.4.0 seams to be the first minor release with new features, however I see no reason to just support all of v2. So far most of the changes aren't big from what I can tell (in terms of user experience, and in terms of breaking changes I think there are none). You might find the improved deprecation notices in the more recent releases to be helpful in developing though

acederberg avatar Jan 09 '24 01:01 acederberg

@acederberg you can just use the v1 namespace https://github.com/pydantic/pydantic/issues/5771

ddorian avatar Jan 09 '24 08:01 ddorian

@bolau and @acederberg Perhaps you should considering following the effort in the pydantic-settings repo for a Pydantic CLI interface that uses Pydantic 2.

It does look like that project has different requirements/goals than pydantic-cli. However, a CLI interface in pydantic-settings does look promising and it could have a larger user base and better documentation than pydantic-cli.

https://github.com/pydantic/pydantic-settings/issues/209

mpkocher avatar Jan 22 '24 12:01 mpkocher

@mpkocher are you planning on adding support for pydantic - 2 in the near future?

yushaer avatar Feb 26 '24 18:02 yushaer

Support for Pydantic v2 has been added.

This has created several backwards incompatible changes. The new API should be more ergonomic and there should be less of a friction point between non-subcommands and subcommand tools.

There's also been some build issues with moving to pyproject.toml that have been resolved. Installing from pypi should work as expected now.

mpkocher avatar Aug 23 '24 03:08 mpkocher