Skip to content

Commit

Permalink
refactor(dependency): use compat.importlib_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mkniewallner committed Sep 15, 2024
1 parent c00532c commit 832a308
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/deptry/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import logging
import re
from contextlib import suppress
from importlib import metadata
from typing import TYPE_CHECKING

from deptry.compat import importlib_metadata

if TYPE_CHECKING:
from collections.abc import Sequence
from importlib.metadata import Distribution
Expand Down Expand Up @@ -83,8 +84,8 @@ def __str__(self) -> str:
@staticmethod
def find_distribution(name: str) -> Distribution | None:
try:
return metadata.distribution(name)
except metadata.PackageNotFoundError:
return importlib_metadata.distribution(name)
except importlib_metadata.PackageNotFoundError:
return None

@staticmethod
Expand Down

0 comments on commit 832a308

Please sign in to comment.