You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "pydantic/validators.py", line 579, in pydantic.validators.find_validators
TypeError: issubclass() arg 1 must be a class
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ptest.py", line 14, in <module>
class Derived(Schema):
File "pydantic/main.py", line 231, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 523, in pydantic.fields.ModelField.populate_validators
File "pydantic/validators.py", line 588, in find_validators
RuntimeError: error checking inheritance of typing.List[str] (type: List[str])
This code sample works in pydantic 1.5.1. The bug seems to rely on the combination of default_factory, the @validator method, and the subclass. Removing any one of these causes the code to run correctly.
Note: there are a few other issues with the similar error message, but they appear to be distinct from this because they apply to versions <= 1.5.1 and have slightly different stack traces.
The text was updated successfully, but these errors were encountered:
Hello @jbeezley
There is already a fix on default_factory#1712, which should fix your issue as well (instead of the error you get the expected ['bar-1']). I updated the description of the PR to add your issue. @samuelcolvin will probably ship a patched version 1.6.1 soon if the fix is approved.
I'm really sorry for the inconvenience.
…#1712)
* fix: validate nested models with `default_factory`
PR #1504 introduced a regression by bypassing `populate_validators()`,
which would skip the validation of children in nested models
with `default_factory`
closes#1710
* test: add example of nested models parsing with `default_factory`
closes#1717
* add testcase from #1722
* bodge for benchmarks
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:This results in
This code sample works in pydantic 1.5.1. The bug seems to rely on the combination of
default_factory
, the@validator
method, and the subclass. Removing any one of these causes the code to run correctly.Note: there are a few other issues with the similar error message, but they appear to be distinct from this because they apply to versions <= 1.5.1 and have slightly different stack traces.
The text was updated successfully, but these errors were encountered: