Skip to content

Commit 8195732

Browse files
authored
Use new importlib.metadata.entry_points interface where available. (#6516)
With Python 3.10, the entry_points() method returning a SelectableGroups dict interface was deprecated. The preferred way is to now filter by group through a keyword argument. Fixes GH6514.
1 parent e13eff2 commit 8195732

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

xarray/backends/plugins.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import inspect
33
import itertools
4+
import sys
45
import warnings
56
from importlib.metadata import entry_points
67

@@ -95,7 +96,11 @@ def build_engines(entrypoints):
9596

9697
@functools.lru_cache(maxsize=1)
9798
def list_engines():
98-
entrypoints = entry_points().get("xarray.backends", ())
99+
# New selection mechanism introduced with Python 3.10. See GH6514.
100+
if sys.version_info >= (3, 10):
101+
entrypoints = entry_points(group="xarray.backends")
102+
else:
103+
entrypoints = entry_points().get("xarray.backends", ())
99104
return build_engines(entrypoints)
100105

101106

0 commit comments

Comments
 (0)