From 5d82233a2074273f057edde7352f2e3b1d54afa8 Mon Sep 17 00:00:00 2001 From: stefan6419846 <96178532+stefan6419846@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:41:15 +0100 Subject: [PATCH] fix importlib.metadata for Python 3.8 --- setup.py | 1 + tests/data.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index bf50707..20013ef 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,7 @@ "mypy", "requests", "types-requests", + "importlib-resources; python_version<3.9", ] }, classifiers=[ diff --git a/tests/data.py b/tests/data.py index b1cdbd1..a45dd79 100644 --- a/tests/data.py +++ b/tests/data.py @@ -3,7 +3,11 @@ # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. from contextlib import contextmanager -from importlib.resources import files, as_file +try: + from importlib.resources import files, as_file +except ImportError: + # Python 3.8 + from importlib_resources import files, as_file # type: ignore from pathlib import Path from typing import Generator @@ -32,7 +36,7 @@ def get_file(name: str) -> Generator[Path, None, None]: SETUP_PY_LICENSES = Licenses( detected_license_expression="apache-2.0 AND (unknown-license-reference AND apache-2.0)", detected_license_expression_spdx="Apache-2.0 AND (LicenseRef-scancode-unknown-license-reference AND Apache-2.0)", - percentage_of_license_text=21.47, + percentage_of_license_text=20.71, license_detections=[ LicenseDetection( license_expression="apache-2.0", @@ -100,8 +104,8 @@ def get_file(name: str) -> Generator[Path, None, None]: matches=[ LicenseMatch( score=95.0, - start_line=45, - end_line=45, + start_line=46, + end_line=46, matched_length=6, match_coverage=100.0, matcher="2-aho", @@ -116,8 +120,8 @@ def get_file(name: str) -> Generator[Path, None, None]: license_clues=[ LicenseClue( score=50.0, - start_line=51, - end_line=51, + start_line=52, + end_line=52, matched_length=3, match_coverage=100.0, matcher="2-aho",