Skip to content

Commit 1b5e8e4

Browse files
authored
Support Python 3.12 (#363)
* support python 3.12 * remove filters * handle pytest warning * try to ignore all pytest warnings * drop 3.7 support
1 parent 7312b7a commit 1b5e8e4

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest, windows-latest, macos-latest]
22-
python-version: ["3.7", "3.11"]
22+
python-version: ["3.8", "3.11"]
2323
include:
2424
- os: windows-latest
2525
python-version: "3.9"
2626
- os: ubuntu-latest
2727
python-version: "pypy-3.8"
2828
- os: ubuntu-latest
29-
python-version: "3.10"
29+
python-version: "3.12.0-beta.1"
3030
- os: macos-latest
31-
python-version: "3.8"
31+
python-version: "3.10"
3232
steps:
3333
- uses: actions/checkout@v3
3434
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

nbformat/sign.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414

1515
try:
1616
import sqlite3
17+
18+
# Use adapters recommended by Python 3.12 stdlib docs.
19+
# https://docs.python.org/3.12/library/sqlite3.html#default-adapters-and-converters-deprecated
20+
def adapt_datetime_iso(val):
21+
"""Adapt datetime.datetime to timezone-naive ISO 8601 date."""
22+
return val.isoformat()
23+
24+
def convert_datetime(val):
25+
"""Convert ISO 8601 datetime to datetime.datetime object."""
26+
return datetime.fromisoformat(val.decode())
27+
28+
sqlite3.register_adapter(datetime, adapt_datetime_iso)
29+
sqlite3.register_converter("datetime", convert_datetime)
1730
except ImportError:
1831
try:
1932
from pysqlite2 import dbapi2 as sqlite3 # type:ignore[no-redef]

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,17 @@ classifiers = [
1515
"License :: OSI Approved :: BSD License",
1616
"Programming Language :: Python",
1717
"Programming Language :: Python :: 3",
18-
"Programming Language :: Python :: 3.7",
1918
"Programming Language :: Python :: 3.8",
2019
"Programming Language :: Python :: 3.9",
2120
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11"
2322
]
24-
requires-python = ">=3.7"
23+
requires-python = ">=3.8"
2524
dependencies = [
2625
"fastjsonschema",
2726
"jsonschema>=2.6",
2827
"jupyter_core",
29-
"traitlets>=5.1",
30-
"importlib-metadata>=3.6;python_version<\"3.8\"",
28+
"traitlets>=5.1"
3129
]
3230

3331
[[project.authors]]
@@ -110,6 +108,8 @@ filterwarnings = [
110108
"error",
111109
"ignore:Using or importing the ABCs from 'collections':DeprecationWarning:jsonschema",
112110
"module:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning",
111+
# ignore pytest warnings.
112+
"ignore:::_pytest",
113113
]
114114

115115
[tool.coverage.report]

0 commit comments

Comments
 (0)