Skip to content

Commit 7d1b70a

Browse files
committed
Test against Python 3.9
1 parent 3c9101b commit 7d1b70a

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

noxfile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import nox
2+
3+
4+
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
5+
def tests(session):
6+
session.install("-e.", "pytest")
7+
session.run("pytest", *session.posargs)

src/whichprovides/__init__.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
__all__ = ["whichprovides", "ProvidedBy"]
1818
__version__ = "0.3.0"
1919

20-
_PACKAGE_MANAGER_BINS: dict[str, str | typing.Literal[False]] = {}
2120
_OS_RELEASE_LINES_RE = re.compile(r"^([A-Z_]+)=(?:\"([^\"]*)\"|(.*))$", re.MULTILINE)
2221
_APK_WHO_OWNS_RE = re.compile(r" is owned by ([^\s\-]+)-([^\s]+)$", re.MULTILINE)
2322
_DPKG_SEARCH_RE = re.compile(r"^([^:]+):")
@@ -30,7 +29,7 @@ class ProvidedBy:
3029
package_type: str
3130
package_name: str
3231
package_version: str
33-
distro: str | None = None
32+
distro: typing.Union[str, None] = None
3433

3534
@property
3635
def purl(self) -> str:
@@ -78,13 +77,13 @@ def os_release() -> dict[str, str]:
7877
return {}
7978

8079
@staticmethod
81-
def distro() -> str | None:
80+
def distro() -> typing.Optional[str]:
8281
return PackageProvider.os_release().get("ID", None)
8382

8483
@classmethod
8584
def which(
86-
cls, bin: str, *, allowed_returncodes: None | set[int] = None
87-
) -> str | None:
85+
cls, bin: str, *, allowed_returncodes: typing.Optional[set[int]] = None
86+
) -> typing.Optional[str]:
8887
"""which, but tries to execute the program, too!"""
8988
cached_bin = cls._has_bin_cache.get(bin)
9089
assert cached_bin is not True
@@ -134,7 +133,7 @@ def whichprovides(cls, filepaths: typing.Collection[str]) -> dict[str, ProvidedB
134133
return results
135134

136135
@classmethod
137-
def whichprovides1(cls, filepath: str) -> ProvidedBy | None:
136+
def whichprovides1(cls, filepath: str) -> typing.Optional[ProvidedBy]:
138137
raise NotImplementedError()
139138

140139

@@ -144,7 +143,7 @@ def is_available(cls) -> bool:
144143
return bool(cls.which("apk") and cls.distro())
145144

146145
@classmethod
147-
def whichprovides1(cls, filepath: str) -> ProvidedBy | None:
146+
def whichprovides1(cls, filepath: str) -> typing.Optional[ProvidedBy]:
148147
apk_bin = cls.which("apk")
149148
distro = cls.distro()
150149
assert apk_bin is not None and distro is not None
@@ -173,7 +172,7 @@ def is_available(cls) -> bool:
173172
return bool(cls.which("rpm") and cls.distro())
174173

175174
@classmethod
176-
def whichprovides1(cls, filepath: str) -> ProvidedBy | None:
175+
def whichprovides1(cls, filepath: str) -> typing.Optional[ProvidedBy]:
177176
rpm_bin = cls.which("rpm")
178177
distro = cls.distro()
179178
assert rpm_bin is not None and distro is not None
@@ -210,7 +209,7 @@ def is_available(cls) -> bool:
210209
return bool(cls.which("dpkg") and cls.distro())
211210

212211
@classmethod
213-
def whichprovides1(cls, filepath: str) -> ProvidedBy | None:
212+
def whichprovides1(cls, filepath: str) -> typing.Optional[ProvidedBy]:
214213
dpkg_bin = cls.which("dpkg")
215214
distro = cls.distro()
216215
assert dpkg_bin is not None and distro is not None
@@ -306,7 +305,7 @@ def all_subclasses(cls):
306305
return sorted(all_subclasses(PackageProvider), key=lambda p: p._resolve_order)
307306

308307

309-
def whichprovides(filepath: str | list[str]) -> dict[str, ProvidedBy]:
308+
def whichprovides(filepath: typing.Union[str, list[str]]) -> dict[str, ProvidedBy]:
310309
"""Return a package URL (PURL) for the package that provides a file"""
311310
if isinstance(filepath, str):
312311
filepaths = [filepath]

0 commit comments

Comments
 (0)