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

Remove lifetime from errors #1084

Merged
merged 1 commit into from
Nov 21, 2023
Merged

Remove lifetime from errors #1084

merged 1 commit into from
Nov 21, 2023

Conversation

davidhewitt
Copy link
Contributor

@davidhewitt davidhewitt commented Nov 20, 2023

Change Summary

Working on integrating the upcoming PyO3 API into pydantic-core, in the short term I'm having to lean into the BorrowInput trait more. There's a lot of pain with respect to lifetimes, especially in the error branches.

This bins off the lifetime in ValError, which will make the problem much simpler.

The only meaningful performance change this will introduce is that we'll now copy string inputs instead of borrow them. In the long term we can find a better solution to this once we've done the PyO3 churn.

Related issue number

N/A

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @dmontagu

Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Merging #1084 (56f0d3c) into main (223aa27) will decrease coverage by 0.02%.
Report is 2 commits behind head on main.
The diff coverage is 94.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1084      +/-   ##
==========================================
- Coverage   89.63%   89.62%   -0.02%     
==========================================
  Files         106      106              
  Lines       16397    16366      -31     
  Branches       35       35              
==========================================
- Hits        14698    14668      -30     
+ Misses       1692     1691       -1     
  Partials        7        7              
Files Coverage Δ
src/errors/line_error.rs 93.05% <100.00%> (+3.40%) ⬆️
src/errors/mod.rs 92.30% <ø> (ø)
src/errors/validation_exception.rs 91.52% <100.00%> (-0.09%) ⬇️
src/errors/value_exception.rs 89.65% <100.00%> (ø)
src/input/datetime.rs 98.77% <100.00%> (ø)
src/input/input_abstract.rs 70.58% <100.00%> (ø)
src/input/input_python.rs 97.84% <100.00%> (+0.01%) ⬆️
src/input/shared.rs 97.39% <100.00%> (ø)
src/lookup_key.rs 92.69% <100.00%> (-0.12%) ⬇️
src/validators/any.rs 100.00% <100.00%> (ø)
... and 43 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2bb53d8...56f0d3c. Read the comment docs.

Copy link

codspeed-hq bot commented Nov 20, 2023

CodSpeed Performance Report

Merging #1084 will not alter performance

Comparing dh/simpler-lifetimes (56f0d3c) with main (2bb53d8)

Summary

✅ 140 untouched benchmarks

@davidhewitt
Copy link
Contributor Author

please review

Copy link
Member

@adriangb adriangb left a comment

Choose a reason for hiding this comment

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

Looks good to me. Maybe this will also open up the door to revisiting the ExceptionGroup stuff. If I recall one of the pain points was that you need to give Python ownership of our Rust exceptions and lifetimes complicate that.

@davidhewitt davidhewitt merged commit be9c21c into main Nov 21, 2023
30 checks passed
@davidhewitt davidhewitt deleted the dh/simpler-lifetimes branch November 21, 2023 07:17
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.

3 participants