Skip to content

Commit d8bef93

Browse files
authored
pytest_plugin.py: replace deprecated pkg_resources with importlib.metadata (#112)
1 parent 137a360 commit d8bef93

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ nbclient = "^0.6.6"
2020
nbformat = "^5.0.8"
2121
Pygments = "^2.7.3"
2222
ipykernel = ">=5.4.0"
23+
importlib-metadata = { version = "^6.8.0", python = "<3.8" }
2324

2425
[tool.poetry.dev-dependencies]
2526
pytest = "^7.1.0"

src/nbmake/pytest_plugin.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from pathlib import Path
44
from typing import Any, Optional
55

6-
import pkg_resources
6+
try:
7+
from importlib.metadata import version
8+
except ImportError:
9+
from importlib_metadata import version
710

811
from .pytest_items import NotebookFile
912

@@ -54,7 +57,7 @@ def pytest_collect_file(path: str, parent: Any) -> Optional[Any]:
5457
opt = parent.config.option
5558
p = Path(path)
5659
if opt.nbmake and p.match("*ipynb") and "_build" not in p.parts:
57-
ver: int = int(pkg_resources.get_distribution("pytest").version[0])
60+
ver: int = int(version("pytest")[0])
5861

5962
if ver < 7:
6063
return NotebookFile.from_parent(parent, fspath=path)

0 commit comments

Comments
 (0)