Skip to content

Commit

Permalink
handle importlib-metadata deprecation
Browse files Browse the repository at this point in the history
importlib-metadata promises that it will start raising KeyError for
missing values, rather than returning None
  • Loading branch information
dimbleby committed Apr 7, 2023
1 parent 860c838 commit 5fd43c0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/poetry/repositories/installed_repository.py
Expand Up @@ -257,9 +257,8 @@ def load(cls, env: Env, with_dependencies: bool = False) -> InstalledRepository:
if path in skipped:
continue

try:
name = canonicalize_name(distribution.metadata["name"])
except TypeError:
name = distribution.metadata.get("name") # type: ignore[attr-defined]
if name is None:
logger.warning(
(
"Project environment contains an invalid distribution"
Expand All @@ -271,6 +270,8 @@ def load(cls, env: Env, with_dependencies: bool = False) -> InstalledRepository:
skipped.add(path)
continue

name = canonicalize_name(distribution.metadata["name"])

if name in seen:
continue

Expand Down

0 comments on commit 5fd43c0

Please sign in to comment.