Skip to content

🗑️ Deprecate const and unique_items in Field - #1732

Open
YuriiMotov wants to merge 8 commits into
mainfrom
deprecate-const-and-unique_items-in-field
Open

🗑️ Deprecate const and unique_items in Field#1732
YuriiMotov wants to merge 8 commits into
mainfrom
deprecate-const-and-unique_items-in-field

Conversation

@YuriiMotov

@YuriiMotov YuriiMotov commented Jan 29, 2026

Copy link
Copy Markdown
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.


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
@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Feb 20, 2026
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Feb 20, 2026
@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Apr 3, 2026
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Apr 3, 2026

@tiangolo tiangolo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙌

Yes, I think it's a good idea to just raise the error, if this has never worked with Pydantic v2, better to not have it around and just show the error.

@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Aug 28, 2026
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Aug 28, 2026
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