Skip to content

Commit

Permalink
[importlib-metadata-] update for importlib-metadata 5.0 API
Browse files Browse the repository at this point in the history
Closes #1550

Related to python/importlib_metadata#409

`entry_points()` does not return dict-like objects anymore. Switch to
using `.select()`.

`.select()` has been around since `importlib-metadata` 3.6, which is our
lowest supported version.
  • Loading branch information
anjakefala committed Oct 5, 2022
1 parent 5d1d405 commit 39cbe73
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions visidata/settings.py
Expand Up @@ -376,12 +376,13 @@ def loadConfigAndPlugins(vd, args=AttrDict()):
if not args.nothing and args_plugins_autoload and vd.options.plugins_autoload:
from importlib_metadata import entry_points # a backport which supports < 3.8 https://github.com/pypa/twine/pull/732
try:
eps = entry_points().get('visidata.plugins', [])
except TypeError:
eps = []
eps = entry_points()
eps_visidata = entry_points().select(group='visidata.plugins') if 'visidata.plugins' in eps.groups else []
except Exception as e:
eps_visidata = []
vd.warning('plugin autoload failed; see issue #1529')

for ep in eps:
for ep in eps_visidata:
try:
plug = ep.load()
sys.modules[f'visidata.plugins.{ep.name}'] = plug
Expand Down

0 comments on commit 39cbe73

Please sign in to comment.