8000 Added schema generation for Generic fields by maximberg · Pull Request #2262 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@maximberg
Copy link
Contributor
@maximberg maximberg commented Jan 14, 2021

Change Summary

Generating schema for generic fields hasn't been implemented. Now it should work.

Related issue number

Fixes #1578.

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)

@codecov
Copy link
codecov bot commented Jan 14, 2021

Codecov Report

Merging #2262 (bf9e4df) into master (13a5c7d) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #2262   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         4199      4205    +6     
  Branches       854       856    +2     
=========================================
+ Hits          4199      4205    +6     
Impacted Files Coverage Δ
pydantic/typing.py 100.00% <ø> (ø)
pydantic/schema.py 100.00% <100.00%> (ø)

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 13a5c7d...bf9e4df. Read the comment docs.

@PrettyWood
Copy link
Collaborator

Hi @maximberg and thanks for the contribution.
I don't know if you saw but #2260 was opened yesterday and tackles the same issue.
Probably good to merge both works!

@maximberg
Copy link
Contributor Author
maximberg commented Jan 14, 2021

Hi @PrettyWood,
I didn't see your pull request yesterday. See what you can add to mine if it's not difficult for you. Tests passed, but coverage decreased.
Thanks )

@maximberg
Copy link
Contributor Author

Coverage restored.

@PrettyWood
Copy link
Collaborator
PrettyWood commented Jan 19, 2021

I didn't see your pull request yesterday. See what you can add to mine if it's not difficult for you. Tests passed, but coverage decreased.

As a matter of fact it's not my PR but @danni's. I just think both works should be merged into one. If this PR is good to go and test cases from @danni's PR are green with your PR fine! But I won't checkout locally both works and do it myself sorry

Co-authored-by: Maz Jaleel <mazjaleel@gmail.com>
@maximberg
Copy link
Contributor Author

@Mazyod Thanks! I used your proposal.

@maximberg
Copy link
Contributor Author
maximberg commented Jan 21, 2021

@PrettyWood Actually @danni's PR is not exactly about problem, described in #1578.

@Mazyod
Copy link
Contributor
Mazyod commented Feb 5, 2021

@samuelcolvin I wanted to sponsor this project because recent generics enhancements will make a big difference for our project 🙇‍♂️ Appreciate your help

@davidhyman
Copy link

👍 here too

I have tried out both #2262 (this) and #2260 MRs and they both work well with my codebase 😄

Currently @danni's MR is indicating lower code coverage. However, two of those tests flag failures on @maximberg's MR (test_nested_generic, test_complex_nested_generic), and I see (but don't fully comprehend) the diff between them.

By way of expediency, perhaps this MR could be merged as-is, providing an improvement? A later MR would then add the nested generic functionality.

In the meantime I will attempt to understand both MRs...

@maximberg
Copy link
Contributor Author

@davidhyman My code solves the problem of generic fields in generating schema.
@danni tries to solve the problem of nested generic models.
In my project I want to use generic fields and I made necessary changes here.

@maximberg
Copy link
Contributor Author
maximberg commented Feb 12, 2021

I found some strange behavior when generic field is Optional. Will check it on Monday, 15th.

@samuelcolvin samuelcolvin merged commit c3870b6 into pydantic:master Feb 13, 2021
@samuelcolvin
Copy link
Member

this looks great, thank you.

If you find other strange behaviour, please create an issue or if you're confident, a PR.

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.

BaseModel.schema() fails when using generic types

5 participants

0