pydantic-core
pydantic-core copied to clipboard
implement omit_trailing_slash feature for PyUrl [7186]
Change Summary
Based on comment https://github.com/pydantic/pydantic/issues/7186#issuecomment-1912192517 implemented omit_trailing_slash feature for PyUrl crate.
Related issue number
https://github.com/pydantic/pydantic/issues/7186
Checklist
- [x] Unit tests for the changes exist
- [x] Documentation reflects the changes where applicable
- [x] Pydantic tests pass with this
pydantic-core(except for expected changes) - [x] My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers
Selected Reviewer: @dmontagu
please review
Codecov Report
Merging #1218 (ca4b802) into main (ab503cb) will increase coverage by
0.08%. Report is 28 commits behind head on main. The diff coverage is100.00%.
Additional details and impacted files
@@ Coverage Diff @@
## main #1218 +/- ##
==========================================
+ Coverage 90.21% 90.29% +0.08%
==========================================
Files 106 106
Lines 16339 16423 +84
Branches 36 39 +3
==========================================
+ Hits 14740 14829 +89
+ Misses 1592 1575 -17
- Partials 7 19 +12
| Files | Coverage Δ | |
|---|---|---|
| python/pydantic_core/core_schema.py | 94.70% <100.00%> (-0.07%) |
:arrow_down: |
| src/serializers/infer.rs | 95.12% <100.00%> (ø) |
|
| src/url.rs | 98.25% <100.00%> (-0.07%) |
:arrow_down: |
| src/validators/url.rs | 97.16% <100.00%> (+0.05%) |
:arrow_up: |
... and 5 files with indirect coverage changes
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update c6301fe...ca4b802. Read the comment docs.
CodSpeed Performance Report
Merging #1218 will not alter performance
Comparing tworedz:omit-trailing-slash (ca4b802) with main (c6301fe)
Summary
✅ 148 untouched benchmarks
Prior art: #1173. Is there a reason why this route should be seen as preferred to the broader suite of normalization bugs which that PR discussed (and ultimately decided we need fixes in rust-url to resolve)?
Prior art: #1173. Is there a reason why this route should be seen as preferred to the broader suite of normalization bugs which that PR discussed (and ultimately decided we need fixes in
rust-urlto resolve)?
In my humble opinion, there seem to be two related yet slightly different issues that we are trying to tackle. The #1173 PR is aimed at fixing the broken Url.build feature, as discussed earlier, and this should be addressed through modifications to rust-url.
Modifying the behavior of rust-url to accommodate URL processing, a functionality relied upon by all users of this crate, appears to be quite challenging. However, from the perspective of pydantic, this was the previous behavior that many projects accepted and utilized, and they aim to continue using it in v2.
What are your thoughts on this?
Let me reflect on this. My instinct is that this is still a rust-url issue, but I may need to prompt discussion upstream.
Thanks!
(Just to set expectations, I've set myself a reminder to explore this next week, when I expect to be also picking up #1085 again. Please ping me if this PR falls off my radar.)
Great! I'll glad to any response)
@davidhewitt Hey, could you please provide updates?)
I have been thinking about this a bit. I would like to avoid the config flag if we can. It seems to me that it's a problem that the URL does not round-trip, and this seems to be a problem of rust-url, which apparently follows the WHATWG URL spec, so I think that first I want to understand if the spec expects this behaviour, or it's a rust-url bug.
@davidhewitt, what do next steps look like here? Do we still plan on attempting to implement this?