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

Replacing encode_default instance check with strict type check #3197

Conversation

joaommartins
Copy link
Contributor

Change Summary

Modifies the schema default resolution of encode_default to resolve IntEnum correctly by introducing a strict type check against primitives. IntEnum defaults are resolved by pydantic_encoder correctly in the same way Enum defaults are resolved.

Related issue number

Closes #3190.

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)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@joaommartins
Copy link
Contributor Author

Please review :)

Copy link
Member

@PrettyWood PrettyWood left a comment

Choose a reason for hiding this comment

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

Please update

pydantic/schema.py Outdated Show resolved Hide resolved
tests/test_schema.py Outdated Show resolved Hide resolved
tests/test_schema.py Outdated Show resolved Hide resolved
changes/3190-joaommartins.md Outdated Show resolved Hide resolved
@joaommartins
Copy link
Contributor Author

Please review. 🙂

@samuelcolvin samuelcolvin merged commit dc4710b into pydantic:master Dec 8, 2021
@joaommartins joaommartins deleted the bugfix/make-schema-encode_default-parse-intenum-correctly branch December 1, 2022 02:52
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.

<Model>.schema() method handles Enum and IntEnum default field resolution differently
3 participants