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: ensure to always return one of the values in Literal field type #2181

Merged

Conversation

PrettyWood
Copy link
Member

@PrettyWood PrettyWood commented Dec 7, 2020

Change Summary

Ensure we always return a value set in Literal even though other values are equal (for example a StrEnum where a string can be equal to a enum member but not identical)

Related issue number

closes #2166

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)

@PrettyWood PrettyWood force-pushed the fix/always-return-litteral-value branch from 0f173c5 to d01bc90 Compare December 7, 2020 09:26
@codecov
Copy link

codecov bot commented Dec 7, 2020

Codecov Report

Merging #2181 (6bd48f5) into master (de0657e) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #2181   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         4121      4122    +1     
  Branches       829       829           
=========================================
+ Hits          4121      4122    +1     
Impacted Files Coverage Δ
pydantic/validators.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 de0657e...6bd48f5. Read the comment docs.

pydantic/validators.py Outdated Show resolved Hide resolved
@PrettyWood PrettyWood force-pushed the fix/always-return-litteral-value branch from 5c880b3 to 3d1ac40 Compare December 10, 2020 08:25
switch from `set` to `dict` to still have a O(1) complexity
Thanks @layday :)
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.

Literal enum fields are stored as mix-in type instead of enum field when using parse_raw or parse_json
4 participants