mirror of https://github.com/celery/kombu.git
Deprecate pytz and use zoneinfo (#1680)
* Main * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * Trigger Build * Fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * Fix * noqas * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove unused noqa * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * re-add import * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * use pytest-freezer (#1683) * Main * Trigger Build * Fixes * remove * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * lint * Lint --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
This commit is contained in:
parent
2de7f9f038
commit
9659f11ae1
|
@ -16,10 +16,10 @@ from vine.utils import wraps
|
|||
|
||||
from kombu.log import get_logger
|
||||
|
||||
try:
|
||||
from pytz import utc
|
||||
except ImportError: # pragma: no cover
|
||||
utc = None
|
||||
if sys.version_info >= (3, 9):
|
||||
from zoneinfo import ZoneInfo
|
||||
else:
|
||||
from backports.zoneinfo import ZoneInfo
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from types import TracebackType
|
||||
|
@ -29,13 +29,13 @@ __all__ = ('Entry', 'Timer', 'to_timestamp')
|
|||
logger = get_logger(__name__)
|
||||
|
||||
DEFAULT_MAX_INTERVAL = 2
|
||||
EPOCH = datetime.utcfromtimestamp(0).replace(tzinfo=utc)
|
||||
EPOCH = datetime.utcfromtimestamp(0).replace(tzinfo=ZoneInfo("UTC"))
|
||||
IS_PYPY = hasattr(sys, 'pypy_version_info')
|
||||
|
||||
scheduled = namedtuple('scheduled', ('eta', 'priority', 'entry'))
|
||||
|
||||
|
||||
def to_timestamp(d, default_timezone=utc, time=monotonic):
|
||||
def to_timestamp(d, default_timezone=ZoneInfo("UTC"), time=monotonic):
|
||||
"""Convert datetime to timestamp.
|
||||
|
||||
If d' is already a timestamp, then that will be used.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
pytz
|
||||
pytest>=7.1.1
|
||||
pytest-sugar
|
||||
Pyro4
|
||||
hypothesis
|
||||
pytest-freezer
|
||||
backports.zoneinfo>=0.2.1; python_version < '3.9'
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import uuid
|
||||
from collections import namedtuple
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
import pytz
|
||||
from hypothesis import given, settings
|
||||
from hypothesis import strategies as st
|
||||
|
||||
from kombu.utils.encoding import str_to_bytes
|
||||
from kombu.utils.json import dumps, loads
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from zoneinfo import ZoneInfo
|
||||
else:
|
||||
from backports.zoneinfo import ZoneInfo
|
||||
|
||||
|
||||
class Custom:
|
||||
|
||||
|
@ -27,7 +32,7 @@ class test_JSONEncoder:
|
|||
@pytest.mark.freeze_time("2015-10-21")
|
||||
def test_datetime(self):
|
||||
now = datetime.utcnow()
|
||||
now_utc = now.replace(tzinfo=pytz.utc)
|
||||
now_utc = now.replace(tzinfo=ZoneInfo("UTC"))
|
||||
|
||||
original = {
|
||||
'datetime': now,
|
||||
|
|
Loading…
Reference in New Issue