Skip to content

Commit

Permalink
plugins.handlers: use stdlib for EntryPointPlugin.get_version()
Browse files Browse the repository at this point in the history
`importlib.metadata` officially starts existing in Python 3.8, and we
are removing support for Python 3.7 before Sopel 8's stable release.
That means we can use the stdlib approach here to get the version string
for an entry-point plugin, and drop another `import importlib_metadata`.

I can't wait for Python 3.9's EOL... We can remove `importlib_metadata`
completely then.
  • Loading branch information
dgw committed Aug 2, 2023
1 parent bef5229 commit f675d27
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions sopel/plugins/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
import sys
from typing import Optional, TYPE_CHECKING, TypedDict

# TODO: refactor along with usage in sopel.__init__ in py3.8+ world
import importlib_metadata

from sopel import __version__ as release, loader, plugin as plugin_decorators
from . import exceptions

Expand Down Expand Up @@ -616,7 +613,7 @@ def get_version(self) -> Optional[str]:

if version is None and hasattr(self.module, "__package__"):
try:
version = importlib_metadata.version(self.module.__package__)
version = importlib.metadata.version(self.module.__package__)
except ValueError:
# package name is probably empty-string; just give up
pass
Expand Down

0 comments on commit f675d27

Please sign in to comment.