Use `__contains__` to avoid `KeyError` with importlib_metadata==8.0.0 (#384)

We don't actually depend on the backport, but a pytest plugin that we
are using, pytest-console-scripts, does.

importlib_metadata==8.0.0 now raises a KeyError when we try to get
metadata that doesn't exist (where before it would return None).

When running the automated tests, we would fail because the backport
would for some reason take precedence over the stdlib. To resolve this,
the current impl is replaced with a __contains__() call.
This commit is contained in:
Kemal Zebari 2024-06-26 12:34:41 -07:00 committed by GitHub
parent 8c56559a9c
commit 5eabebe114
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -93,7 +93,7 @@ def filter_valid_distributions(iterable_dists: Iterable[Distribution]) -> list[D
def has_valid_metadata(dist: Distribution) -> bool:
return dist.metadata["Name"] is not None
return "Name" in dist.metadata
def render_invalid_metadata_text(site_dirs_with_invalid_metadata: set[str]) -> None: