From 246a65b22b58d868f7dcad7c70d33a7e350ddba2 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Fri, 7 Apr 2023 11:58:52 +0100 Subject: [PATCH] handle importlib-metadata deprecation importlib-metadata promises that it will start raising KeyError for missing values, rather than returning None --- src/poetry/repositories/installed_repository.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/poetry/repositories/installed_repository.py b/src/poetry/repositories/installed_repository.py index 2a3496ac5ba..cbdb738a66e 100644 --- a/src/poetry/repositories/installed_repository.py +++ b/src/poetry/repositories/installed_repository.py @@ -257,9 +257,7 @@ def load(cls, env: Env, with_dependencies: bool = False) -> InstalledRepository: if path in skipped: continue - try: - name = canonicalize_name(distribution.metadata["name"]) - except TypeError: + if "name" not in distribution.metadata: logger.warning( ( "Project environment contains an invalid distribution" @@ -271,6 +269,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