<Model>.schema() method handles Enum and IntEnum default field resolution differently #3190
Closed
3 tasks done
Labels
bug V1
Bug related to Pydantic V1.X
Checks
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:Generating a schema with the .schema() method works as expected when resolving default values of Enum type, while it does not resolve default values of IntEnum type the same way. A minimum example follows:
I've tracked the issue down to the
encode_default
function inschema.py
:When resolving defaults for Enum the else clause is correctly used, but since
isinstance(ExampleIntEnum.A, int)
is truthy it returns ExampleIntEnum.A when using an IntEnum. I would suggest changing the first if to a stricter direct 'primitive' type check likeif type(dft) in (int, float, str):
.I can do this myself and open a PR if there is interest and no opposition to a stricter type check.
The text was updated successfully, but these errors were encountered: