Skip to content

Commit 549f5a7

Browse files
.
1 parent acb92f3 commit 549f5a7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

sentry_sdk/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,8 @@ def _generate_installed_modules():
17571757

17581758
def _normalize_module_name(name):
17591759
# type: (str) -> str
1760-
return name.lower()
1760+
# https://peps.python.org/pep-0503/#normalized-names
1761+
return re.sub(r"[-_.]+", "-", name).lower()
17611762

17621763

17631764
def _get_installed_modules():
@@ -1770,8 +1771,10 @@ def _get_installed_modules():
17701771

17711772
def package_version(package):
17721773
# type: (str) -> Optional[Tuple[int, ...]]
1774+
normalized_package = _normalize_module_name(package)
1775+
17731776
installed_packages = _get_installed_modules()
1774-
version = installed_packages.get(package)
1777+
version = installed_packages.get(normalized_package)
17751778
if version is None:
17761779
return None
17771780

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from typing import Any
2323

2424

25-
HF_VERSION = package_version("huggingface-hub") or package_version("huggingface_hub")
25+
HF_VERSION = package_version("huggingface-hub")
2626

2727
if HF_VERSION and HF_VERSION < (0, 30, 0):
2828
MODEL_ENDPOINT = "https://api-inference.huggingface.co/models/{model_name}"

0 commit comments

Comments
 (0)