Skip to content

Commit

Permalink
fix mypy issue with importlib imports, see pydata#5979
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuehlbauer committed Nov 14, 2021
1 parent e132893 commit 697b112
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions xarray/backends/plugins.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import functools
import inspect
import itertools
import sys
import warnings

from .common import BACKEND_ENTRYPOINTS, BackendEntrypoint

try:
if sys.version_info >= (3, 8):
from importlib.metadata import entry_points
except ImportError:
else:
# if the fallback library is missing, we are doomed.
from importlib_metadata import entry_points # type: ignore[no-redef]
from importlib_metadata import entry_points


STANDARD_BACKENDS_ORDER = ["netcdf4", "h5netcdf", "scipy"]
Expand Down
7 changes: 4 additions & 3 deletions xarray/tests/test_plugins.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import sys
from unittest import mock

import pytest

from xarray.backends import common, plugins

try:
if sys.version_info >= (3, 8):
from importlib.metadata import EntryPoint

importlib_metadata_mock = "importlib.metadata"
except ImportError:
else:
# if the fallback library is missing, we are doomed.
from importlib_metadata import EntryPoint # type: ignore[no-redef]
from importlib_metadata import EntryPoint

importlib_metadata_mock = "importlib_metadata"

Expand Down

0 comments on commit 697b112

Please sign in to comment.