Skip to content

Commit

Permalink
plugins.handlers: warn when version determination fails
Browse files Browse the repository at this point in the history
  • Loading branch information
SnoopJ committed Oct 30, 2024
1 parent 566c51a commit bb0487e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions sopel/plugins/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import importlib.util
import inspect
import itertools
import logging
import os
import sys
from typing import Optional, TYPE_CHECKING, TypedDict
Expand All @@ -61,6 +62,9 @@
from types import ModuleType


LOGGER = logging.getLogger(__name__)


class PluginMetaDescription(TypedDict):
"""Meta description of a plugin, as a dictionary.
Expand Down Expand Up @@ -623,11 +627,17 @@ def get_version(self) -> Optional[str]:
and hasattr(self.entry_point, "dist")
and hasattr(self.entry_point.dist, "name")
):
dist_name = self.entry_point.dist.name
try:
version = importlib.metadata.version(self.entry_point.dist.name)
version = importlib.metadata.version(dist_name)
except (ValueError, importlib.metadata.PackageNotFoundError):
LOGGER.warning("Cannot determine version of %r", dist_name)
except Exception:
# fine, just give up
pass
LOGGER.warning(
"Unexpected error occurred while checking the version of %r",
dist_name,
exc_info=True,
)

return version

Expand Down

0 comments on commit bb0487e

Please sign in to comment.