Skip to content

Conversation

hmvp
Copy link
Contributor

@hmvp hmvp commented Sep 29, 2020

Change Summary

Fix issue where const validator was not used

Related issue number

closes #1956

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 Sep 29, 2020

Codecov Report

Merging #1957 into master will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #1957   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         3909      3909           
  Branches       788       788           
=========================================
  Hits          3909      3909           
Impacted Files Coverage Δ
pydantic/fields.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 bf9cc4a...3bf9f7f. Read the comment docs.

@hmvp
Copy link
Contributor Author

hmvp commented Oct 9, 2020

@samuelcolvin If you find the time, would you consider reviewing and merging this bugfix?

@samuelcolvin
Copy link
Member

This looks fine to me, but I'm worried there must have been a good reason the += was omitted.

Is there any case you can think of that this could break?

@hmvp
Copy link
Contributor Author

hmvp commented Oct 9, 2020

Well it breaks code that relies on const validators not running when custom validators are present which I find odd behaviour to want.. The added test is an example of that.

BTW in 1.5.x this did work and the added test would not fail (that is why I found the issue in the first place, when upgrading to 1.6.1 and having a test fail)

I suspect the plus was left out because this code moved around a bit and that line use to be the first place the post_validators where filled..

@samuelcolvin samuelcolvin merged commit c6a24f2 into pydantic:master Oct 9, 2020
@samuelcolvin
Copy link
Member

makes sense, thank you.

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.

BUG: Const validator is not called when there are class validators
2 participants