Skip to content

Conversation

oldPadavan
Copy link
Contributor

Implements #182

@codecov
Copy link

codecov bot commented Jun 27, 2018

Codecov Report

Merging #209 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #209      +/-   ##
==========================================
+ Coverage   99.84%   99.84%   +<.01%     
==========================================
  Files          11       11              
  Lines        1285     1300      +15     
  Branches      235      237       +2     
==========================================
+ Hits         1283     1298      +15     
  Misses          2        2

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

Otherwise, I think looks good.

if arbitrary_types_allowed:
return [make_arbitrary_type_validator(type_)]
else:
raise errors.ConfigError(f'no validator found for {type_}')
Copy link
Member

Choose a reason for hiding this comment

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

This should be a RuntimeError, it's not a config problem and will happen at runtime.


with pytest.raises(ValidationError) as exc_info:
ArbitraryTypeAllowedModel(t=C())
assert exc_info.value.errors() == [
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please test your changes with exc_info.value.json()? I don't think that ctx with type is JSON serializable. To my mind we need to use utils.display_as_type when we firing ArbitraryTypeError exception.

@@ -204,3 +204,10 @@ class UUIDVersionError(PydanticValueError):

def __init__(self, *, required_version: int) -> None:
super().__init__(required_version=required_version)


class ArbitraryTypeError(PydanticTypeError):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think for better readability we need to define code = 'type_error.arbitrary_type' or rename class to ArbitraryError

@samuelcolvin samuelcolvin merged commit 73015d2 into pydantic:master Jul 2, 2018
@Gr1N Gr1N mentioned this pull request Jul 2, 2018
alexdrydew pushed a commit to alexdrydew/pydantic that referenced this pull request Dec 23, 2023
* Allow functions within model_class validators

* make fields_set flexible

* improve coverage

* fix error message test to support pypy
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.

3 participants