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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a feature flag system #2194
Comments
Yeah sounds good, would love to be involved in developing this. |
Possibly, though first off this issue sounds like a perfect candidate for GitHub's new I'm not sure how that would be implemented, though I don't think an env var is the best way to go, and pydantic hasn't historically used a conf file. I believe setting a Config var in BaseModel/Settings classes would be the best, since that's already the primary interface, and would allow for comparison between features, and would be explicit, thus "method of least surprise". |
Unfortunately we don't have the new discussions feature but I completely agree. Maybe @samuelcolvin can activate it in the repo settings. |
Yeah, my thought was limiting it to per-model config would be better, but that would be a pain if one wants to enact global changes for all of pydantic. Perhaps introducing a But on to the On further thought, an alpha release seems better since breaking changes wouldn't necessarily keep the old behavior around, so some things might be an all-or-nothing approach. |
I think talking about alpha releases of |
Would you want to alter the behaviour of all Pydantic models in your dependency tree? Is this not something model config could accomodate? You could add a new setting which emits a deprecation warning when it's set to |
Yes. The "create your own subclass" feels a bit annoying and hacky to really promote new default behaviours from pydantic import BaseConfig
BaseConfig.my_disabled_option_by_default = True to change globally the behaviour of pydantic models instead of defining their own custom |
Related issue: #2003 |
I've just seen this issue, sorry for the slow reply. I've enabled discussions, I'll change the issue template to point to them for questions and suggest feature requests should seek approval in discussions before becoming issues. I've thought about this quite a lot and I'm overall opposed to feature flags for pydantic unless absolutely necessary. I think this is arguably a case of tragedy of the commons - the more complex features and confusing configuration settings we add, the harder pydantic becomes to use for everyone. My point of view is described perfectly on this prettier issue: prettier/prettier#40 In particular the following line resonates with me:
(I came to that issue when researching how to setup On the specific idea of global singleton that modifies all pydantic behaviour, I think this is a bad idea for the following reasons:
Global configuration belongs to frameworks, not libraries. pydantic is a library, not a framework. I think the current The route problem is that progress of pydantic has slowed down somewhat. The solutions for this are:
The reason this has come up is that I have 50 PRs to review whenever I look at pydantic which means I'm less inclined than I might otherwise be to work on pydantic (no one enjoys reviewing PRs as much as writing code). Even when I do work on pydantic I have two or three days of work reviewing PRs before I can work on any of the big behaviour changes people want. I never thought I would say this but there are too many people creating too many PRs! |
Thanks a lot @samuelcolvin for the thoughtful and detailed explanation.
as well. It will definitely stay up there in my head! I probably tried too hard - and I'm sorry for that I'll stop opening so many PRs - to try to close issues without impacting the library or taking a step back from time to time. With the benefit of hindsight it makes perfect sense. |
Sorry @PrettyWood, you've misinterpreted what I said (maybe my mistake). Your PRs are not the problem at all, in fact they help because they implement bigger changes and take little time to review. Please keep creating PRs! |
Hi everyone!
Holidays are coming soon 馃巺 and I'm planning on working more on pydantic (currently it's mostly on my
veryshort nights 馃槃)For example I would like to work on the
StrictUnion
or the@computed_field
and try to close a bunch of issues.But while working on a very easy to fix issue like this one, I stopped thinking:
"Wait Eric, this is a breaking change. Is it that big of a deal? I don't know! 馃"
Furthermore there are some issues where people want/expect a different global behaviour that could be easily done already and handled by a feature flag (for example all fields without default value are required, even the
Optional
ones, switching fromre.match
tore.search
for the regex in fields, having a strict mode...)And this is why I reckon we could benefit from a feature flag system
This would allow us to be less reluctant to make changes and start working for some features of v2 for example
And start adding warning messages like "careful this will be removed in v2...".
Seeing how pydantic is getting popular and how busy @samuelcolvin is, I think we really need to prepare the ground in order to work without stress on the new big features with possible breaking changes
I don't know yet how we would set those feature flags. It could be env variables, config module or/and file or anything else...feedback more than welcome! Here is a very basic example of what could be done.
@samuelcolvin @tiangolo @StephenBrown2 @dmontagu, anyone else?
The text was updated successfully, but these errors were encountered: