From b67ee9eb5424fa6a95a873f732bee4d9c71b9fe5 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 4 Nov 2023 20:01:38 -0500 Subject: [PATCH 1/4] clean up config and address warnings --- jupyter_server/_tz.py | 20 +++++++------------- pyproject.toml | 16 ++-------------- tests/test_gateway.py | 2 +- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/jupyter_server/_tz.py b/jupyter_server/_tz.py index 24847b4307..df123ffe07 100644 --- a/jupyter_server/_tz.py +++ b/jupyter_server/_tz.py @@ -7,8 +7,7 @@ # Distributed under the terms of the Modified BSD License. from __future__ import annotations -from datetime import datetime, timedelta, tzinfo -from typing import Callable +from datetime import datetime, timedelta, timezone, tzinfo # constant for zero offset ZERO = timedelta(0) @@ -26,21 +25,16 @@ def dst(self, d: datetime | None) -> timedelta: return ZERO -UTC = tzUTC() # type:ignore[abstract] - +def utcnow() -> datetime: + """Return timezone-aware UTC timestamp""" + return datetime.now(timezone.utc) -def utc_aware(unaware: Callable[..., datetime]) -> Callable[..., datetime]: - """decorator for adding UTC tzinfo to datetime's utcfoo methods""" - def utc_method(*args, **kwargs): - dt = unaware(*args, **kwargs) - return dt.replace(tzinfo=UTC) +def utcfromtimestamp(timestamp): + return datetime.fromtimestamp(timestamp, timezone.utc) - return utc_method - -utcfromtimestamp = utc_aware(datetime.utcfromtimestamp) -utcnow = utc_aware(datetime.utcnow) +UTC = tzUTC() # type:ignore[abstract] def isoformat(dt: datetime) -> str: diff --git a/pyproject.toml b/pyproject.toml index 5971262c02..946f8c3074 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,10 +20,6 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", ] requires-python = ">=3.8" dependencies = [ @@ -249,7 +245,7 @@ minversion = "6.0" xfail_strict = true log_cli_level = "info" addopts = [ - "-raXs", "--durations=10", "--color=yes", "--doctest-modules", + "-ra", "--durations=10", "--color=yes", "--doctest-modules", "--showlocals", "--strict-markers", "--strict-config" ] testpaths = [ @@ -265,14 +261,6 @@ filterwarnings = [ "always:unclosed Date: Sat, 4 Nov 2023 20:10:15 -0500 Subject: [PATCH 2/4] fix warning --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 946f8c3074..4beabaeeb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -261,6 +261,7 @@ filterwarnings = [ "always:unclosed Date: Sat, 4 Nov 2023 20:30:59 -0500 Subject: [PATCH 3/4] fix warning --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4beabaeeb4..7b87f91c24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -261,7 +261,7 @@ filterwarnings = [ "always:unclosed Date: Sat, 4 Nov 2023 20:45:43 -0500 Subject: [PATCH 4/4] fix warning --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 7b87f91c24..0f7b639828 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -262,6 +262,7 @@ filterwarnings = [ "module:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning", "ignore:jupyter_server.base.zmqhandlers module is deprecated in Jupyter Server 2.0:DeprecationWarning", "ignore:datetime.datetime.utc:DeprecationWarning:dateutil", + "ignore:datetime.datetime.utc:DeprecationWarning:tornado", ] [tool.coverage.report]