Skip to content

Commit 5d01090

Browse files
Use .name for Requirement() instead of relying on regex
Co-authored-by: Isaac To <candleindark@users.noreply.github.com>
1 parent d567f3e commit 5d01090

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

dandi/pytest_plugin.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import annotations
22

3-
import re
43
from importlib.metadata import PackageNotFoundError, requires, version
54

65
from dandischema.models import DandiBaseModel
6+
from packaging.requirements import Requirement
77
from pytest import Config, Item, Parser
88

99
from .tests.fixtures import * # noqa: F401, F403 # lgtm [py/polluting-import]
@@ -41,11 +41,7 @@ def pytest_report_header(config: Config) -> list[str]:
4141
# Extract package names from requirement strings.
4242
# Format: "package-name >= 1.0" or "package-name ; condition"
4343
# and by regex thus we skip extras (in square brackets like [test])
44-
deps = {
45-
match.group(1)
46-
for dep in (requires("dandi") or [])
47-
if (match := re.match(r"^([a-zA-Z0-9_-]+)", dep))
48-
}
44+
deps = {Requirement(dep).name for dep in (requires("dandi") or [])}
4945
except PackageNotFoundError:
5046
# Use defaults if we didn't get deps from metadata
5147
deps = {"dandischema", "h5py", "hdmf"}

0 commit comments

Comments
 (0)