150 lines
4.3 KiB
Diff
150 lines
4.3 KiB
Diff
Taken from https://github.com/jupyter/jupyter_client/pull/972/
|
|
|
|
From 493366dd9e11736c32d32b1d84f5fa56d9ee74ab Mon Sep 17 00:00:00 2001
|
|
From: Mattias Ellert <mattias.ellert@physics.uu.se>
|
|
Date: Mon, 11 Sep 2023 06:37:16 +0200
|
|
Subject: [PATCH 1/4] Do not use datetime.utcnow() that is deprecated in Python
|
|
3.12
|
|
|
|
Import session.utcnow() into utils instead of reimplementing it
|
|
---
|
|
jupyter_client/session.py | 2 +-
|
|
jupyter_client/utils.py | 34 +---------------------------------
|
|
2 files changed, 2 insertions(+), 34 deletions(-)
|
|
|
|
diff --git a/jupyter_client/session.py b/jupyter_client/session.py
|
|
index ca9d9bbe..ee172d53 100644
|
|
--- a/jupyter_client/session.py
|
|
+++ b/jupyter_client/session.py
|
|
@@ -197,7 +197,7 @@ def default_secure(cfg: t.Any) -> None: # pragma: no cover
|
|
|
|
def utcnow() -> datetime:
|
|
"""Return timezone-aware UTC timestamp"""
|
|
- return datetime.utcnow().replace(tzinfo=utc) # noqa
|
|
+ return datetime.now(utc) # noqa
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
diff --git a/jupyter_client/utils.py b/jupyter_client/utils.py
|
|
index ab1cbcaa..4e2943c0 100644
|
|
--- a/jupyter_client/utils.py
|
|
+++ b/jupyter_client/utils.py
|
|
@@ -4,10 +4,10 @@
|
|
- vendor functions from ipython_genutils that should be retired at some point.
|
|
"""
|
|
import os
|
|
-from datetime import datetime, timedelta, tzinfo
|
|
|
|
from jupyter_core.utils import ensure_async, run_sync # noqa: F401 # noqa: F401
|
|
|
|
+from .session import utcnow
|
|
|
|
def _filefind(filename, path_dirs=None):
|
|
"""Find a file by looking through a sequence of paths.
|
|
@@ -84,35 +84,3 @@ def _expand_path(s):
|
|
if os.name == "nt":
|
|
s = s.replace("IPYTHON_TEMP", "$\\")
|
|
return s
|
|
-
|
|
-
|
|
-# constant for zero offset
|
|
-ZERO = timedelta(0)
|
|
-
|
|
-
|
|
-class tzUTC(tzinfo): # noqa
|
|
- """tzinfo object for UTC (zero offset)"""
|
|
-
|
|
- def utcoffset(self, d):
|
|
- """Compute utcoffset."""
|
|
- return ZERO
|
|
-
|
|
- def dst(self, d):
|
|
- """Compute dst."""
|
|
- return ZERO
|
|
-
|
|
-
|
|
-UTC = tzUTC() # type:ignore
|
|
-
|
|
-
|
|
-def utc_aware(unaware):
|
|
- """decorator for adding UTC tzinfo to datetime's utcfoo methods"""
|
|
-
|
|
- def utc_method(*args, **kwargs):
|
|
- dt = unaware(*args, **kwargs)
|
|
- return dt.replace(tzinfo=UTC)
|
|
-
|
|
- return utc_method
|
|
-
|
|
-
|
|
-utcnow = utc_aware(datetime.utcnow)
|
|
|
|
From 5468546499f5071171bcb8bccafe034837cc092d Mon Sep 17 00:00:00 2001
|
|
From: "pre-commit-ci[bot]"
|
|
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
|
|
Date: Mon, 11 Sep 2023 04:44:48 +0000
|
|
Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks
|
|
|
|
for more information, see https://pre-commit.ci
|
|
---
|
|
jupyter_client/utils.py | 1 +
|
|
1 file changed, 1 insertion(+)
|
|
|
|
diff --git a/jupyter_client/utils.py b/jupyter_client/utils.py
|
|
index 4e2943c0..0186a001 100644
|
|
--- a/jupyter_client/utils.py
|
|
+++ b/jupyter_client/utils.py
|
|
@@ -9,6 +9,7 @@
|
|
|
|
from .session import utcnow
|
|
|
|
+
|
|
def _filefind(filename, path_dirs=None):
|
|
"""Find a file by looking through a sequence of paths.
|
|
|
|
|
|
From d78c153d819fb3da3dc80f916747291b5200a302 Mon Sep 17 00:00:00 2001
|
|
From: David Brochart <david.brochart@gmail.com>
|
|
Date: Mon, 11 Sep 2023 09:22:41 +0200
|
|
Subject: [PATCH 3/4] Remove unneeded noqa
|
|
|
|
---
|
|
jupyter_client/session.py | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/jupyter_client/session.py b/jupyter_client/session.py
|
|
index ee172d53..e22c9d44 100644
|
|
--- a/jupyter_client/session.py
|
|
+++ b/jupyter_client/session.py
|
|
@@ -197,7 +197,7 @@ def default_secure(cfg: t.Any) -> None: # pragma: no cover
|
|
|
|
def utcnow() -> datetime:
|
|
"""Return timezone-aware UTC timestamp"""
|
|
- return datetime.now(utc) # noqa
|
|
+ return datetime.now(utc)
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
From 7ba40db1c6fb505e95df4cf4c3f9176661f2f270 Mon Sep 17 00:00:00 2001
|
|
From: David Brochart <david.brochart@gmail.com>
|
|
Date: Mon, 11 Sep 2023 09:22:57 +0200
|
|
Subject: [PATCH 4/4] Add noqa
|
|
|
|
---
|
|
jupyter_client/utils.py | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/jupyter_client/utils.py b/jupyter_client/utils.py
|
|
index 0186a001..9f1c38e9 100644
|
|
--- a/jupyter_client/utils.py
|
|
+++ b/jupyter_client/utils.py
|
|
@@ -7,7 +7,7 @@
|
|
|
|
from jupyter_core.utils import ensure_async, run_sync # noqa: F401 # noqa: F401
|
|
|
|
-from .session import utcnow
|
|
+from .session import utcnow # noqa
|
|
|
|
|
|
def _filefind(filename, path_dirs=None):
|