-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
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
validate_call trying to parse an enum.StrEnum as an int #9437
Comments
I tried using typing.Collection instead of typing.Sequence and it failed with
so I ended creating my own Collection type hint using the below code and that seems to work.
Thanks to whoever took the time to write the Handling custom generic classes documentation. I couldn't have done this without it working example
|
Thanks for the bug report. At a first glance, definitely looks like a problem, maybe relating to our new core enum parsing logic. Here's a more minimal example: import enum
import typing
import pydantic
class PropertyName(str, enum.Enum):
PERIOD = "Period"
VALUE_CODE = "Value Code"
@pydantic.validate_call
def get_item_property_values(
properties: str | PropertyName | int | typing.Sequence[PropertyName | str | int] | typing.Iterable[int] | None = None,
) -> list:
return [
list(properties)
]
resp = get_item_property_values(
properties={"A", 1, PropertyName.PERIOD, "B", 2, PropertyName.VALUE_CODE},
)
print(f"{resp=}") Looks like the same issue doesn't arise in the case of a |
Initial Checks
Description
Unable to pass a set with a StrEnum, int and str to an argument with a type hint of str | PropertyName | int | typing.Sequence[PropertyName | str | int] | typing.Iterable[int] | None
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: