Skip to content

Commit bb0487e

Browse files
committed
plugins.handlers: warn when version determination fails
1 parent 566c51a commit bb0487e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

sopel/plugins/handlers.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import importlib.util
4949
import inspect
5050
import itertools
51+
import logging
5152
import os
5253
import sys
5354
from typing import Optional, TYPE_CHECKING, TypedDict
@@ -61,6 +62,9 @@
6162
from types import ModuleType
6263

6364

65+
LOGGER = logging.getLogger(__name__)
66+
67+
6468
class PluginMetaDescription(TypedDict):
6569
"""Meta description of a plugin, as a dictionary.
6670
@@ -623,11 +627,17 @@ def get_version(self) -> Optional[str]:
623627
and hasattr(self.entry_point, "dist")
624628
and hasattr(self.entry_point.dist, "name")
625629
):
630+
dist_name = self.entry_point.dist.name
626631
try:
627-
version = importlib.metadata.version(self.entry_point.dist.name)
632+
version = importlib.metadata.version(dist_name)
633+
except (ValueError, importlib.metadata.PackageNotFoundError):
634+
LOGGER.warning("Cannot determine version of %r", dist_name)
628635
except Exception:
629-
# fine, just give up
630-
pass
636+
LOGGER.warning(
637+
"Unexpected error occurred while checking the version of %r",
638+
dist_name,
639+
exc_info=True,
640+
)
631641

632642
return version
633643

0 commit comments

Comments
 (0)