Skip to content

Commit

Permalink
Suppress warnings when 'importlib_metadata' has been imported twice.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Sep 11, 2024
1 parent dc96731 commit 7290346
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion importlib_metadata/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def localize_dist(
return importlib_metadata.PathDistribution(
cast(importlib_metadata._meta.SimplePath, dist._path)
)
warnings.warn(f"Unrecognized distribution subclass {dist.__class__}")
# workaround for when pytest has replaced importlib_metadata
# https://github.com/python/importlib_metadata/pull/505#issuecomment-2344329001
if dist.__class__.__module__ != 'importlib_metadata':
warnings.warn(f"Unrecognized distribution subclass {dist.__class__}")
return cast(importlib_metadata.Distribution, dist)


Expand Down

0 comments on commit 7290346

Please sign in to comment.