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
I have searched Google & GitHub for similar requests and couldn't find anything
I have read and followed the docs and still think this feature is missing
Description
This fails:
fromdatetimeimportdatetimefrompydanticimportAfterValidator, TypeAdapterfromtyping_extensionsimportAnnotatedISOTimestamp=Annotated[datetime, AfterValidator(datetime.isoformat)]
print(TypeAdapter(ISOTimestamp).validate_python(1651576501.0))
# ValueError: no signature found for builtin <method 'isoformat' of 'datetime.datetime' objects>
A simple workaround is to call datetime.isoformat from a lambda, but that's a bit ugly.
inspect_validator excludes builtins from the inspection that fails, but does not exclude methods like datetime.timestamp from the inspection. I think it should. Or give the user control over whether the inspection takes place.
I agree that it'd be nice if this just worked, but it's going to be hard to special case everything.
Maybe if we can't get the signature we can assume one, e.g. a single argument that is the input value?
Initial Checks
Description
This fails:
A simple workaround is to call
datetime.isoformat
from a lambda, but that's a bit ugly.inspect_validator excludes builtins from the inspection that fails, but does not exclude methods like
datetime.timestamp
from the inspection. I think it should. Or give the user control over whether the inspection takes place.Affected Components
.model_dump()
and.model_dump_json()
model_construct()
, pickling, private attributes, ORM modeSelected Assignee: @adriangb
The text was updated successfully, but these errors were encountered: