Skip to content

Commit

Permalink
Merge pull request #2268 from sopel-irc/importlib_metadata-pls
Browse files Browse the repository at this point in the history
deps: forget about `python_version` specifier for `importlib_metadata`
  • Loading branch information
dgw authored Mar 17, 2022
2 parents daee42c + 48cabf5 commit 8b463a0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ geoip2>=4.0,<5.0
requests>=2.24.0,<3.0.0
dnspython<3.0
sqlalchemy>=1.4,<1.5
importlib_metadata>=3.6; python_version < '3.10'
importlib_metadata>=3.6
packaging
8 changes: 3 additions & 5 deletions sopel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
import re
import sys

try:
import importlib.metadata as importlib_metadata
except ImportError:
# TODO: remove fallback when dropping py3.7
import importlib_metadata
# TODO: replace with stdlib importlib.metadata when dropping py3.7
# version info used in this module works from py3.8+
import importlib_metadata

__all__ = [
'bot',
Expand Down
11 changes: 5 additions & 6 deletions sopel/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
import itertools
import os

try:
import importlib_metadata
except ImportError:
# TODO: use stdlib only when possible, after dropping py3.9
# stdlib does not support `entry_points(group='filter')` until py3.10
import importlib.metadata as importlib_metadata
# TODO: use stdlib importlib.metadata when possible, after dropping py3.9.
# Stdlib does not support `entry_points(group='filter')` until py3.10, but
# fallback logic is more trouble than it's worth when e.g. clean Ubuntu
# py3.10 envs include old versions of this backport.
import importlib_metadata

from . import exceptions, handlers, rules # noqa

Expand Down
6 changes: 4 additions & 2 deletions sopel/plugins/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,10 @@ class EntryPointPlugin(PyModulePlugin):
Entry points are a `standard packaging mechanism`__ for Python, used by
other applications (such as ``pytest``) for their plugins.
The ``importlib_metadata`` backport package is used on Python versions
older than 3.10, but its API is the same as :mod:`importlib.metadata`.
The ``importlib_metadata`` backport package is used for consistency
across all of Sopel's supported Python versions. Its API matches that
of :mod:`importlib.metadata` from Python 3.10 and up; Sopel will drop
this external requirement when practical.
.. __: https://packaging.python.org/en/latest/specifications/entry-points/
Expand Down
8 changes: 2 additions & 6 deletions test/plugins/test_plugins_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
import os
import sys

# TODO: use stdlib importlib.metadata when dropping py3.9
import importlib_metadata
import pytest

try:
import importlib.metadata as importlib_metadata
except ImportError:
# TODO: remove fallback when dropping py3.9
import importlib_metadata

from sopel.plugins import handlers


Expand Down
8 changes: 2 additions & 6 deletions test/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@

import sys

# TODO: switch to stdlib importlib.metdata when dropping py3.9
import importlib_metadata
import pytest

try:
import importlib.metadata as importlib_metadata
except ImportError:
# TODO: remove fallback when dropping py3.9
import importlib_metadata

from sopel import plugins


Expand Down

2 comments on commit 8b463a0

@dgw
Copy link
Member Author

@dgw dgw commented on 8b463a0 Mar 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF, Coveralls???

@dgw
Copy link
Member Author

@dgw dgw commented on 8b463a0 Mar 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passed when re-run, but the commit status (at time of writing) is still an ugly ❌

So much for our green streak.

Please sign in to comment.