We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
MultiValueEnum
pydantic>=2.7
Hi,
After bumping pydantic to 2.7 version I've noticed that it's not possible to instantiate a Pydantic class having an attr of type aenum.MultiValueEnum.
pydantic
2.7
aenum.MultiValueEnum
Pydantic detects only the canonical value and raises a validation error when given other accepted values.
An example Model definition:
from pydantic import BaseModel from aenum import MultiValueEnum class MultiEnum(MultiValueEnum): NAME = "VAL", "value" class SomeModel(BaseModel): attr: MultiEnum
When using canonical value VAL the model is created:
VAL
SomeModel(attr="VAL") SomeModel(attr=<MultiEnum.NAME: 'VAL'>)
When using other value the model fails:
SomeModel(attr="value") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/pysetup/.venv/lib/python3.11/site-packages/pydantic/main.py", line 175, in __init__ self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 1 validation error for SomeModel attr Input should be 'VAL' [type=enum, input_value='value', input_type=str] For further information visit https://errors.pydantic.dev/2.7/v/enum
Could this problem be resolved by a fix in the aenum package or would it require action from Pydantic maintainers?
aenum
Pydantic
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
After bumping
pydantic
to2.7
version I've noticed that it's not possible to instantiate a Pydantic class having an attr of typeaenum.MultiValueEnum
.Pydantic detects only the canonical value and raises a validation error when given other accepted values.
An example Model definition:
When using canonical value
VAL
the model is created:When using other value the model fails:
Could this problem be resolved by a fix in the
aenum
package or would it require action fromPydantic
maintainers?The text was updated successfully, but these errors were encountered: