-
Notifications
You must be signed in to change notification settings - Fork 250
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
Expose API for setting the global "show errors in reprs" flag #1118
Conversation
Dear reviewers, please review 😄 |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1118 +/- ##
==========================================
+ Coverage 89.70% 89.75% +0.04%
==========================================
Files 106 106
Lines 16364 16371 +7
Branches 35 35
==========================================
+ Hits 14680 14693 +13
+ Misses 1677 1671 -6
Partials 7 7
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
33c64f1
to
b6f8aec
Compare
CodSpeed Performance ReportMerging #1118 will not alter performanceComparing Summary
|
b6f8aec
to
1f3b2c8
Compare
1f3b2c8
to
2fb9cc0
Compare
It looks like the Codspeed benchmark is a bit flaky – pushing non-code changes made it oscillate between "perf bad" and "this is fine". |
@akx thanks for this proposal. The Codspeed benchmark does indeed have some volatility at the moment, which we hope to improve with #1085 Regarding the feature added here, if I recall correctly @samuelcolvin, @adriangb and myself were discussing something very similar just last week. I think we came to the conclusion that having this as a global setting had some drawbacks. As an alternative, we wondered if it would make sense to have this as a property on errors, so on each |
It kind of already is a global setting, namely the undocumented environment variable. 😁
That means I'd have to look through all of my codebase (and dependencies that might use Pydantic), and set the property before anything happens to There's something of a precedent in the form of |
Yes, but an environment variable which we read once rather than mutable state.
Potentially, what's your use case which means that the environment variable at startup isn't useful to you? |
If the issue is the possible perf loss from having to read the GILProtected value once per
The environment variable works for me personally, but if the canonical way to disable the URLs app-wide is the envvar, then it should be at least documented 😄 |
I asked @samuelcolvin about this earlier today, agreed we should make this public and documented but would prefer to flip it around to have |
I can look into making a PR implementing that instead today :) Emdraftened this for the time being. |
Superseded by #1123 |
Change Summary
This PR adds a public API to set the global "include documentation URLs in error reprs" flag that was previously only available via the undocumented
PYDANTIC_ERRORS_OMIT_URL
environment variable (which was only read once aspydantic_core
was initialized, and couldn't be changed afterwards).To do that, the GILOnceCell holding the value was changed to a lower-level GILProtected.
Related issue number
pydantic/pydantic#7485 is tangentially related.
Checklist
pydantic-core
(except for expected changes)Selected Reviewer: @dmontagu