Skip to content

Commit 4b68e0c

Browse files
committed
fix: restore support for python>=3.7,<3.9
1 parent 6d9f6ef commit 4b68e0c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

jupyterlab_code_formatter/formatters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
import rpy2.robjects
1515
except ImportError:
1616
pass
17-
from functools import cache
17+
if sys.version_info >= (3, 9):
18+
from functools import cache
19+
else:
20+
from functools import lru_cache
21+
cache = lru_cache(maxsize=None)
1822

1923
from packaging import version
2024

jupyterlab_code_formatter/tests/test_handlers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import json
2+
import sys
23
import typing as t
3-
from importlib.metadata import version
4+
if sys.version_info >= (3, 8):
5+
from importlib.metadata import version
6+
else:
7+
from importlib_metadata import version
48

59
import pytest
610
from jsonschema import validate

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ test = [
5151
"blue==0.9.1",
5252
"isort",
5353
"yapf",
54+
"importlib_metadata; python_version<'3.8'",
5455
]
5556

5657
[tool.hatch.envs.default]

0 commit comments

Comments
 (0)