Skip to content

Conversation

hramezani
Copy link
Member

@hramezani hramezani commented Jul 25, 2023

Selected Reviewer: @Kludex

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-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 force-pushed the deprecate-field-include branch from 42a0f88 to 510f961 Compare July 26, 2023 09:26
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.

2 participants