Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Field.include #6852

Merged
merged 2 commits into from Jul 26, 2023
Merged

Deprecate Field.include #6852

merged 2 commits into from Jul 26, 2023

Conversation

hramezani
Copy link
Member

@hramezani hramezani commented Jul 25, 2023

Selected Reviewer: @Kludex

@cloudflare-pages
Copy link

cloudflare-pages bot commented Jul 25, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 510f961
Status: ✅  Deploy successful!
Preview URL: https://24ca2a59.pydantic-docs2.pages.dev
Branch Preview URL: https://deprecate-field-include.pydantic-docs2.pages.dev

View logs

@hramezani
Copy link
Member Author

please review

id: int = Field(..., include=True)
username: str = Field(..., include=True) # overridden by explicit include
id: int
username: str # overridden by explicit include
Copy link
Member

Choose a reason for hiding this comment

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

Does this makes sense still?

Copy link
Member Author

@hramezani hramezani Jul 26, 2023

Choose a reason for hiding this comment

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

No, I've just removed it.

@@ -793,6 +785,10 @@ def Field( # noqa: C901
if validation_alias in (_Unset, None):
validation_alias = alias

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', DeprecationWarning)
Copy link
Member

Choose a reason for hiding this comment

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

AFAIU, this is not a deprecation... If the functionality is removed, it's a removal. The parameter itself is deprecated.

Also, how is exclude a replacement for include? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAIU, this is not a deprecation... If the functionality is removed, it's a removal. The parameter itself is deprecated.

I think it is a deprecation as it did nothing before and still does nothing. So, no change in functionality. just warning the user.

Also, how is exclude a replacement for include? 🤔

include=False can be replaced with exclude=True. That's why I suggested using exclude.

@hramezani hramezani merged commit e245682 into main Jul 26, 2023
48 checks passed
@hramezani hramezani deleted the deprecate-field-include branch July 26, 2023 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants