Skip to content

Set info.data and info.field_name for dataclass field validators #454

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

Merged
merged 2 commits into from
Mar 17, 2023

Conversation

adriangb
Copy link
Member

No description provided.

@codecov-commenter
Copy link

Codecov Report

Merging #454 (d373e11) into main (653308f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #454   +/-   ##
=======================================
  Coverage   95.36%   95.37%           
=======================================
  Files          93       93           
  Lines       11115    11124    +9     
  Branches       22       22           
=======================================
+ Hits        10600    10609    +9     
  Misses        510      510           
  Partials        5        5           
Impacted Files Coverage Δ
src/validators/dataclass.rs 97.53% <100.00%> (+0.08%) ⬆️

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 653308f...d373e11. Read the comment docs.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 17, 2023

CodSpeed Performance Report

Merging #454 dataclass-fields (d373e11) will not alter performances.

Summary

🔥 0 improvements
❌ 0 regressions
✅ 93 untouched benchmarks

🆕 0 new benchmarks
⁉️ 0 dropped benchmarks

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

LGTM

let extra = Extra {
field_name: Some(&field.name),
..extra
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems necessary, but do we have any benchmarks that would pick up on performance impact of this? Not sure it matters.

@dmontagu
Copy link
Collaborator

Looks good to me with the only possible concern being the creation of more Extra for each field of the dataclass. Not sure if that is avoidable in theory, or how expensive it is to create an Extra anyway.

I think if there's any interest in eliminating the copying of Extra (e.g., if it were expensive to create copies for some reason, I haven't looked at the definition so I'm not sure), at this stage it would make sense to just put a comment indicating this in the code and revisit at a later time rather than put effort into eliminating the copying now.

Copy link
Collaborator

@dmontagu dmontagu left a comment

Choose a reason for hiding this comment

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

Okay I looked it up, considering Extra is just four optional references and a bool I think performance impact should be pretty negligible.

@adriangb
Copy link
Member Author

It's also what we already do elsewhere:

let extra = Extra {
data: Some(output_dict),
field_name: Some(&field.name),
..*extra
};

@adriangb adriangb merged commit 3f96b09 into main Mar 17, 2023
@adriangb adriangb deleted the dataclass-fields branch March 17, 2023 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants