Skip to content

Conversation

@YuriiMotov
Copy link
Member

const and unique_items parameters in Field are deprecated in Pydantic V2 (const, unique_items):

    const = extra.pop('const', None)  # type: ignore
    if const is not None:
        raise PydanticUserError('`const` is removed, use `Literal` instead', code='removed-kwargs')
...

    unique_items = extra.pop('unique_items', None)  # type: ignore
    if unique_items is not None:
        raise PydanticUserError(
            (
                '`unique_items` is removed, use `Set` instead'
                '(this feature is discussed in https://github.com/pydantic/pydantic-core/issues/296)'
            ),
            code='removed-kwargs',
        )

This PR reflects this change.

I ended up just emitting a warning (not error) in case someone use these parameters. Should we also raise error as Pydantic does?


These parameters don't work (just ignored) on current SQLModel version. And they never worked with SQLMOdel + Pydantic V2.
So, not sure we need to mark this PR as breaking, but I did it it worked in some previous versions with Pydantic V1

@YuriiMotov YuriiMotov marked this pull request as ready for review January 29, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants