pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/fastapi/sqlmodel/pull/1724

ets/global-0bd78641c0a1f3e0.css" /> 🏷️ Fix typing for `exclude` parameter of `Field`, deprecate `include` parameter by YuriiMotov · Pull Request #1724 · fastapi/sqlmodel · GitHub
Skip to content

🏷️ Fix typing for exclude parameter of Field, deprecate include parameter#1724

Open
YuriiMotov wants to merge 7 commits intomainfrom
fix-field-exclude-parameter-typing
Open

🏷️ Fix typing for exclude parameter of Field, deprecate include parameter#1724
YuriiMotov wants to merge 7 commits intomainfrom
fix-field-exclude-parameter-typing

Conversation

@YuriiMotov
Copy link
Copy Markdown
Member

@YuriiMotov YuriiMotov commented Jan 28, 2026

The type of exclude parameter is just bool | None in Pydantic V2, set and dict are not allowed anymore (sources).

from pydantic import BaseModel, Field

class User(BaseModel):
    id: int
    username: str

class Transaction(BaseModel):
    id: str
    user: User = Field(..., exclude={'username'})

user = User(id=1, username='alice')
transaction = Transaction(id='txn_123', user=user)

print(transaction.model_dump())

# pydantic_core._pydantic_core.SchemaError: Error building `model` serializer:
#   SchemaError: Error building `model-fields` serializer:
#   TypeError: 'set' object cannot be converted to 'PyBool'

I updated type hint and added a simple test for this parameter.


I also deprecated the include parameter as it's useless (doesn't do anything) in Pydantic V2.

From Pydantic sources:

    include = extra.pop('include', None)  # type: ignore
    if include is not None:
        warn(
            '`include` is deprecated and does nothing. It will be removed, use `exclude` instead',
            PydanticDeprecatedSince20,
            stacklevel=2,
        )

@YuriiMotov YuriiMotov changed the title 🏷️ Fix typing for exclude parameter to Field, removed include parameter 🏷️ Fix typing for exclude parameter of Field, remove include parameter Jan 28, 2026
@YuriiMotov

This comment was marked as resolved.

@YuriiMotov YuriiMotov marked this pull request as draft January 31, 2026 23:33
@github-actions github-actions bot added the conflicts Automatically generated when a PR has a merge conflict label Feb 1, 2026
@github-actions

This comment was marked as resolved.

1 similar comment
@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 3, 2026
@YuriiMotov YuriiMotov marked this pull request as ready for review February 3, 2026 09:33
@YuriiMotov YuriiMotov changed the title 🏷️ Fix typing for exclude parameter of Field, remove include parameter 🏷️ Fix typing for exclude parameter of Field, deprecate include parameter Feb 3, 2026
@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
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

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy