Repository: HypothesisWorks/hypothesis

Issue:
importlib-metadata DeprecationWarning
Seen on https://github.com/adamchainz/mariadb-dyncol/pull/298 

```
   File "/home/runner/work/mariadb-dyncol/mariadb-dyncol/.tox/py37/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 170, in exec_module
    exec(co, module.__dict__)
  File "/home/runner/work/mariadb-dyncol/mariadb-dyncol/.tox/py37/lib/python3.7/site-packages/hypothesis/__init__.py", line 61, in <module>
    run()
  File "/home/runner/work/mariadb-dyncol/mariadb-dyncol/.tox/py37/lib/python3.7/site-packages/hypothesis/entry_points.py", line 61, in run
    for entry in get_entry_points():  # pragma: no cover
  File "/home/runner/work/mariadb-dyncol/mariadb-dyncol/.tox/py37/lib/python3.7/site-packages/hypothesis/entry_points.py", line 32, in get_entry_points
    yield from importlib_metadata.entry_points().get("hypothesis", [])
  File "/home/runner/work/mariadb-dyncol/mariadb-dyncol/.tox/py37/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 312, in get
    flake8_bypass(self._warn)()
DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
ERROR: InvocationError for command /home/runner/work/mariadb-dyncol/mariadb-dyncol/.tox/py37/bin/python -W error::DeprecationWarning -W error::PendingDeprecationWarning -m pytest (exited with code 1)
```


Discussion:
[changelog](https://importlib-metadata.readthedocs.io/en/latest/history.html)

This can be solved by depending on `importlib-metadata` 3.9.0+ on Python < 3.10 and using the select interface, OR by using [backports.entry-points-selectable](https://pypi.org/project/backports.entry-points-selectable/).
We've written a fair bit of extra code to ensure that our entry-points logic doesn't add a hard dependency; so I think the best option is to use `select` if it's available in 

https://github.com/HypothesisWorks/hypothesis/blob/0e7f87dc053615b25597edc02b6d08f0fcaf4b73/hypothesis-python/src/hypothesis/entry_points.py#L31-L32

and fall back to the existing logic on older versions.  Thanks for the report 😄 
Why not add a dependency on importlib-metadata? That’s what I’ve done in pytest-randomly to avoid this deprecation warning.

Resolving patch:
diff --git a/hypothesis-python/setup.py b/hypothesis-python/setup.py
--- a/hypothesis-python/setup.py
+++ b/hypothesis-python/setup.py
@@ -81,7 +81,7 @@ def local_file(name):
 }
 
 extras["all"] = sorted(
-    set(sum(extras.values(), ["importlib_metadata ; python_version<'3.8'"]))
+    set(sum(extras.values(), ["importlib_metadata>=3.6; python_version<'3.8'"]))
 )
 
 
diff --git a/hypothesis-python/src/hypothesis/entry_points.py b/hypothesis-python/src/hypothesis/entry_points.py
--- a/hypothesis-python/src/hypothesis/entry_points.py
+++ b/hypothesis-python/src/hypothesis/entry_points.py
@@ -29,7 +29,14 @@
         import importlib_metadata  # type: ignore  # mypy thinks this is a redefinition
 
     def get_entry_points():
-        yield from importlib_metadata.entry_points().get("hypothesis", [])
+        try:
+            eps = importlib_metadata.entry_points(group="hypothesis")
+        except TypeError:
+            # Load-time selection requires Python >= 3.10 or importlib_metadata >= 3.6,
+            # so we'll retain this fallback logic for some time to come.  See also
+            # https://importlib-metadata.readthedocs.io/en/latest/using.html
+            eps = importlib_metadata.entry_points().get("hypothesis", [])
+        yield from eps
 
 
 except ImportError:


Test patch: