From bb30cb3cfe57f326addec21a6cae5f81184c2e74 Mon Sep 17 00:00:00 2001 From: Kevin Kirsche Date: Thu, 30 Nov 2023 09:59:11 -0500 Subject: [PATCH] Update type_decorator example to align with python docs This change updates the `TZDateTime` type decorator to use the timezone awareness checks described in the Python documentation located here: https://docs.python.org/3/library/datetime.html#determining-if-an-object-is-aware-or-naive The specific lines state: > A `datetime` object `d` is aware if both of the following hold: > >```python d.tzinfo is not None d.tzinfo.utcoffset(d) does not return None ``` > >Otherwise, `d` is naive. --- doc/build/core/custom_types.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/build/core/custom_types.rst b/doc/build/core/custom_types.rst index 6ae9e066ac..3642314c08 100644 --- a/doc/build/core/custom_types.rst +++ b/doc/build/core/custom_types.rst @@ -156,7 +156,7 @@ denormalize:: def process_bind_param(self, value, dialect): if value is not None: - if not value.tzinfo: + if not value.tzinfo and not value.tzinfo.utcoffset(value): raise TypeError("tzinfo is required") value = value.astimezone(datetime.timezone.utc).replace(tzinfo=None) return value -- 2.47.3