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

Fix root_validator issues with optional fields and made meta optional #145

Merged
merged 7 commits into from Jan 24, 2020

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Jan 23, 2020

After some fiddling, it seems like all that needed to be done was set pre=True in the remaining root validators, otherwise "data" seems to get validated first and popped from the response dict? (unsure)

I've also had to make meta optional for EntryResponseOne and EntryResponseMany, which changes the openapi spec. I'm not sure how I feel about this...

@ml-evs ml-evs changed the title Set pre=true for all root validators Fix root_validator issues with optional fields and made meta optional Jan 23, 2020
@ml-evs ml-evs requested a review from CasperWA January 23, 2020 10:51
@codecov
Copy link

codecov bot commented Jan 23, 2020

Codecov Report

Merging #145 into master will not change coverage.
The diff coverage is 25%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #145   +/-   ##
=======================================
  Coverage   85.79%   85.79%           
=======================================
  Files          39       39           
  Lines        1830     1830           
=======================================
  Hits         1570     1570           
  Misses        260      260
Flag Coverage Δ
#unittests 85.79% <25%> (ø) ⬆️
Impacted Files Coverage Δ
optimade/models/optimade_json.py 83.33% <ø> (ø) ⬆️
optimade/models/jsonapi.py 90% <ø> (ø) ⬆️
optimade/validator/validator.py 62.33% <25%> (ø) ⬆️

Continue to review full report at Codecov.

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

@CasperWA
Copy link
Member

After some fiddling, it seems like all that needed to be done was set pre=True in the remaining root validators, otherwise "data" seems to get validated first and popped from the response dict? (unsure)

Right! That makes sense - sort of :)

I've also had to make meta optional for EntryResponseOne and EntryResponseMany, which changes the openapi spec. I'm not sure how I feel about this...

This is fine. meta is OPTIONAL after all, with respect to the spec.

Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Very good fix. Thanks @ml-evs.

I have only a small change request for consistency.

optimade/models/jsonapi.py Outdated Show resolved Hide resolved
optimade/models/optimade_json.py Outdated Show resolved Hide resolved
@CasperWA
Copy link
Member

Very good fix. Thanks @ml-evs.

I have only a small change request for consistency.

I have just pushed the fix myself - I hope you agree with it as well? I will just wait for your input and otherwise merge it.

CasperWA
CasperWA previously approved these changes Jan 24, 2020
optimade/models/jsonapi.py Outdated Show resolved Hide resolved
@ml-evs ml-evs requested a review from CasperWA January 24, 2020 10:48
@ml-evs
Copy link
Member Author

ml-evs commented Jan 24, 2020

Cheers @CasperWA, I've just been even pickier with the language :P Hope you still accept!

Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Great with extra nit-picky pickyness @ml-evs 😅

@ml-evs ml-evs merged commit 51df1b3 into master Jan 24, 2020
@CasperWA CasperWA deleted the ml-evs/root_validator branch January 24, 2020 10:51
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.

None yet

2 participants