Skip to content

Commit

Permalink
fix importlib.metadata for Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan6419846 committed Dec 8, 2023
1 parent 43bc9e5 commit 5d82233
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"mypy",
"requests",
"types-requests",
"importlib-resources; python_version<3.9",
]
},
classifiers=[
Expand Down
16 changes: 10 additions & 6 deletions tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 5d82233

Please sign in to comment.