From fbb8dde826f5c32ef3db5c046eb81a73c902241a Mon Sep 17 00:00:00 2001 From: Ben Warner Date: Fri, 29 Jul 2022 15:53:38 -0700 Subject: [PATCH] PYTHON-3375 Added docstrings to DatetimeConversionOpts (#1024) * Added docstrings * Fixed detail * Fixed punctuation and links Co-authored-by: Ben Warner --- bson/codec_options.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/bson/codec_options.py b/bson/codec_options.py index afffa2f12..bceab5e00 100644 --- a/bson/codec_options.py +++ b/bson/codec_options.py @@ -200,10 +200,38 @@ class TypeRegistry(object): class DatetimeConversionOpts(enum.IntEnum): + """Options for decoding BSON datetimes.""" + DATETIME = 1 + """Decode a BSON UTC datetime as a :class:`datetime.datetime`. + + BSON UTC datetimes that cannot be represented as a + :class:`~datetime.datetime` will raise an :class:`OverflowError` + or a :class:`ValueError`. + + .. versionadded 4.3 + """ + DATETIME_CLAMP = 2 + """Decode a BSON UTC datetime as a :class:`datetime.datetime`, clamping + to :attr:`~datetime.datetime.min` and :attr:`~datetime.datetime.max`. + + .. versionadded 4.3 + """ + DATETIME_MS = 3 + """Decode a BSON UTC datetime as a :class:`~bson.datetime_ms.DatetimeMS` + object. + + .. versionadded 4.3 + """ + DATETIME_AUTO = 4 + """Decode a BSON UTC datetime as a :class:`datetime.datetime` if possible, + and a :class:`~bson.datetime_ms.DatetimeMS` if not. + + .. versionadded 4.3 + """ class _BaseCodecOptions(NamedTuple):