##// END OF EJS Templates
Fix pdb issues in Python 3.13.1 (#14598)...
Fix pdb issues in Python 3.13.1 (#14598) For some reason it is not always set, it was/is a bug in IPython to not check.

File last commit:

r28532:1cbca0b4
r28973:be84e4b5 merge
Show More
tz.py
82 lines | 2.0 KiB | text/x-python | PythonLexer
MinRK
add IPython.utils.tz...
r11144 # encoding: utf-8
"""
Timezone utilities
Just UTC-awareness right now
Nils Müller
Add deprecation docstrings and warning.
r28523
Deprecated since IPython 8.19.0.
MinRK
add IPython.utils.tz...
r11144 """
Nils Müller
Format existing code with black
r28522 # -----------------------------------------------------------------------------
MinRK
add IPython.utils.tz...
r11144 # 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.
Nils Müller
Format existing code with black
r28522 # -----------------------------------------------------------------------------
MinRK
add IPython.utils.tz...
r11144
Nils Müller
Format existing code with black
r28522 # -----------------------------------------------------------------------------
MinRK
add IPython.utils.tz...
r11144 # Imports
Nils Müller
Format existing code with black
r28522 # -----------------------------------------------------------------------------
MinRK
add IPython.utils.tz...
r11144
Nils Müller
Add deprecation docstrings and warning.
r28523 import warnings
MinRK
add IPython.utils.tz...
r11144 from datetime import tzinfo, timedelta, datetime
Nils Müller
Format existing code with black
r28522 # -----------------------------------------------------------------------------
MinRK
add IPython.utils.tz...
r11144 # Code
Nils Müller
Format existing code with black
r28522 # -----------------------------------------------------------------------------
Nils Müller
Add deprecation docstrings and warning.
r28523 __all__ = ["tzUTC", "utc_aware", "utcfromtimestamp", "utcnow"]
Nils Müller
Add _warn_deprecated()
r28524
MinRK
add IPython.utils.tz...
r11144 # constant for zero offset
ZERO = timedelta(0)
Nils Müller
Format existing code with black
r28522
Nils Müller
Add deprecation docstrings and warning.
r28523 def __getattr__(name):
if name not in __all__:
err = f"IPython.utils.tz is deprecated and has no attribute {name}"
raise AttributeError(err)
Nils Müller
Add _warn_deprecated()
r28524 _warn_deprecated()
Nils Müller
Add deprecation docstrings and warning.
r28523
return getattr(name)
Nils Müller
Add _warn_deprecated()
r28524 def _warn_deprecated():
msg = "The module `IPython.utils.tz` is deprecated and will be completely removed."
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
MinRK
add IPython.utils.tz...
r11144 class tzUTC(tzinfo):
Nils Müller
Add deprecation docstrings and warning.
r28523 """tzinfo object for UTC (zero offset)
Deprecated since IPython 8.19.0.
"""
MinRK
add IPython.utils.tz...
r11144
Nils Müller
Add _warn_deprecated()
r28524 _warn_deprecated()
MinRK
add IPython.utils.tz...
r11144 def utcoffset(self, d):
return ZERO
def dst(self, d):
return ZERO
Matthias Bussonnier
MAINT: refactor/please mypy....
r28167
UTC = tzUTC() # type: ignore[abstract]
MinRK
add IPython.utils.tz...
r11144
def utc_aware(unaware):
Nils Müller
Add deprecation docstrings and warning.
r28523 """decorator for adding UTC tzinfo to datetime's utcfoo methods
Deprecated since IPython 8.19.0.
"""
Nils Müller
Format existing code with black
r28522
MinRK
add IPython.utils.tz...
r11144 def utc_method(*args, **kwargs):
Nils Müller
Add _warn_deprecated()
r28524 _warn_deprecated()
MinRK
add IPython.utils.tz...
r11144 dt = unaware(*args, **kwargs)
return dt.replace(tzinfo=UTC)
Nils Müller
Format existing code with black
r28522
MinRK
add IPython.utils.tz...
r11144 return utc_method
Nils Müller
Format existing code with black
r28522
MinRK
add IPython.utils.tz...
r11144 utcfromtimestamp = utc_aware(datetime.utcfromtimestamp)
utcnow = utc_aware(datetime.utcnow)