Skip to content

Commit f424551

Browse files
committed
Fix type annotations
1 parent 76a912e commit f424551

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/plotting/_core.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import importlib
4+
import types
45
from typing import (
56
TYPE_CHECKING,
67
Sequence,
@@ -1727,7 +1728,7 @@ def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwargs):
17271728
return self(kind="hexbin", x=x, y=y, C=C, **kwargs)
17281729

17291730

1730-
_backends = {}
1731+
_backends: dict[str, types.ModuleType] = {}
17311732

17321733

17331734
def _load_backend(backend: str):
@@ -1745,20 +1746,20 @@ def _load_backend(backend: str):
17451746
types.ModuleType
17461747
The imported backend.
17471748
"""
1749+
module: types.ModuleType | None = None
1750+
17481751
if backend == "matplotlib":
17491752
# Because matplotlib is an optional dependency and first-party backend,
17501753
# we need to attempt an import here to raise an ImportError if needed.
17511754
try:
1752-
import pandas.plotting._matplotlib as module
1755+
module = __import__("pandas.plotting._matplotlib")
17531756
except ImportError:
17541757
raise ImportError(
17551758
"matplotlib is required for plotting when the "
17561759
'default backend "matplotlib" is selected.'
17571760
) from None
17581761
return module
17591762

1760-
module = None
1761-
17621763
for entry_point in pkg_resources.iter_entry_points("pandas_plotting_backends"):
17631764
if entry_point.name == backend:
17641765
module = entry_point.load()

0 commit comments

Comments
 (0)