diff options
author | AlexSm <alex@ydb.tech> | 2024-01-09 18:56:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-09 18:56:40 +0100 |
commit | e95f266d2a3e48e62015220588a4fd73d5d5a5cb (patch) | |
tree | a8a784b6931fe52ad5f511cfef85af14e5f63991 /contrib/python/ipython/py3/IPython/utils/tz.py | |
parent | 50a65e3b48a82d5b51f272664da389f2e0b0c99a (diff) | |
download | ydb-e95f266d2a3e48e62015220588a4fd73d5d5a5cb.tar.gz |
Library import 6 (#888)
Diffstat (limited to 'contrib/python/ipython/py3/IPython/utils/tz.py')
-rw-r--r-- | contrib/python/ipython/py3/IPython/utils/tz.py | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/contrib/python/ipython/py3/IPython/utils/tz.py b/contrib/python/ipython/py3/IPython/utils/tz.py index dbe1e8e732..ba1199d274 100644 --- a/contrib/python/ipython/py3/IPython/utils/tz.py +++ b/contrib/python/ipython/py3/IPython/utils/tz.py @@ -3,29 +3,56 @@ Timezone utilities Just UTC-awareness right now + +Deprecated since IPython 8.19.0. """ -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # Copyright (C) 2013 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # Imports -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +import warnings from datetime import tzinfo, timedelta, datetime -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # Code -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +__all__ = ["tzUTC", "utc_aware", "utcfromtimestamp", "utcnow"] + + # constant for zero offset ZERO = timedelta(0) + +def __getattr__(name): + if name not in __all__: + err = f"IPython.utils.tz is deprecated and has no attribute {name}" + raise AttributeError(err) + + _warn_deprecated() + + return getattr(name) + + +def _warn_deprecated(): + msg = "The module `IPython.utils.tz` is deprecated and will be completely removed." + warnings.warn(msg, category=DeprecationWarning, stacklevel=2) + + class tzUTC(tzinfo): - """tzinfo object for UTC (zero offset)""" + """tzinfo object for UTC (zero offset) + + Deprecated since IPython 8.19.0. + """ + + _warn_deprecated() def utcoffset(self, d): return ZERO @@ -38,11 +65,18 @@ UTC = tzUTC() # type: ignore[abstract] def utc_aware(unaware): - """decorator for adding UTC tzinfo to datetime's utcfoo methods""" + """decorator for adding UTC tzinfo to datetime's utcfoo methods + + Deprecated since IPython 8.19.0. + """ + def utc_method(*args, **kwargs): + _warn_deprecated() dt = unaware(*args, **kwargs) return dt.replace(tzinfo=UTC) + return utc_method + utcfromtimestamp = utc_aware(datetime.utcfromtimestamp) utcnow = utc_aware(datetime.utcnow) |