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
Datetimes without timezones encode as strings, since the msgpacktimestamp extension only represents datetimes with timezones.
When decoding, the decoder has no way to know that the value should be interpreted as a datetime rather than a string unless you provide it a type annotation representing the expected schema.
In [1]: importdatetimeIn [2]: importmsgspecIn [3]: dt=datetime.datetime.now()
In [4]: encoded=msgspec.msgpack.encode(dt)
In [5]: msgspec.msgpack.decode(encoded) # no type annotationOut[5]: '2024-03-14T13:28:46.058671'In [6]: msgspec.msgpack.decode(encoded, type=datetime.datetime) # with type annotationOut[6]: datetime.datetime(2024, 3, 14, 13, 28, 46, 58671)
Description
python==3.11.0rc1
msgspec==0.18.6
Maybe related to #534 ?
The text was updated successfully, but these errors were encountered: