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

Bugfix for generic types with parameterized generic fields #672

merged 4 commits into from Jul 24, 2019


Copy link

@dmontagu dmontagu commented Jul 17, 2019

Change Summary

Fixes a bug where a generic parameter exists alongside a fully-parameterized generic parameter in the model.

Related issue number

Fixes a bug discovered while answering #668


  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • HISTORY.rst has been updated
    • if this is the first change since a release, please add a new section
    • include the issue number or this pull request number #<number>
    • include your github username @<whomever>

return type_.__origin__[new_args]
new_args = tuple([typevars_map[x] for x in type_.__parameters__])
return type_[new_args]
if hasattr(type_, '__origin__') and getattr(type_, '__parameters__', None):
Copy link
Collaborator Author

@dmontagu dmontagu Jul 17, 2019

Choose a reason for hiding this comment

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

This is closer to the way typing handles determining whether a type is generic than the prior implementation (in addition to being simpler).

Copy link

codecov bot commented Jul 17, 2019

Codecov Report

Merging #672 into master will not change coverage.
The diff coverage is n/a.

@@          Coverage Diff          @@
##           master   #672   +/-   ##
  Coverage     100%   100%           
  Files          15     15           
  Lines        2712   2712           
  Branches      537    537           
  Hits         2712   2712

@samuelcolvin samuelcolvin merged commit b09e697 into pydantic:master Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants