Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Tests/test_pyroma.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,32 @@

from PIL import __version__

TYPE_CHECKING = False

if TYPE_CHECKING:
from importlib.metadata import PackageMetadata

pyroma = pytest.importorskip("pyroma", reason="Pyroma not installed")


def map_metadata_keys(md):
def map_metadata_keys(md: PackageMetadata) -> dict[str, str | list[str] | None]:
# Convert installed wheel metadata into canonical Core Metadata 2.4 format.
# This was a utility method in pyroma 4.3.3; it was removed in 5.0.
# This implementation is constructed from the relevant logic from
# Pyroma 5.0's `build_metadata()` implementation. This has been submitted
# upstream to Pyroma as https://github.com/regebro/pyroma/pull/116,
# so it may be possible to simplify this test in future.
data = {}
for key in set(md.keys()):
for key in set(md):
value = md.get_all(key)
key = pyroma.projectdata.normalize(key)

if len(value) == 1:
value = value[0]
if value.strip() == "UNKNOWN":
continue

data[key] = value
if value is not None and len(value) == 1:
first_value = value[0]
if first_value.strip() != "UNKNOWN":
data[key] = first_value
else:
data[key] = value
return data


Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ testpaths = [
python_version = "3.10"
pretty = true
disallow_any_generics = true
disallow_untyped_defs = true
enable_error_code = "ignore-without-code"
extra_checks = true
follow_imports = "silent"
Expand Down
Loading