Skip to content

Commit 28b3000

Browse files
committed
TYP: fix a couple errors flagged by pyright
1 parent 4b791bb commit 28b3000

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/cmasher/_handlercolorpolycollection.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1+
import sys
2+
13
import numpy as np
24
from matplotlib.legend_handler import HandlerBase
35

6+
if sys.version_info >= (3, 12):
7+
from typing import override
8+
else:
9+
from typing_extensions import override
10+
411

512
# Define legend handler class for artists that use colormaps
613
class _HandlerColorPolyCollection(HandlerBase):
714
# Override create_artists to create an AxesImage resembling a colormap
15+
@override
816
def create_artists(
9-
self, legend, artist, xdescent, ydescent, width, height, fontsize, trans
17+
self, legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans
1018
):
1119
from matplotlib.image import AxesImage
1220

1321
# Obtain the Axes object of this legend
1422
ax = legend.axes
1523

1624
# Obtain the colormap of the artist
17-
cmap = artist.cmap
25+
cmap = orig_handle.cmap
1826

1927
# Create an AxesImage to contain the colormap with proper dimensions
2028
image = AxesImage(
21-
ax, cmap=cmap, transform=trans, extent=[xdescent, width, ydescent, height]
29+
ax, cmap=cmap, transform=trans, extent=(xdescent, width, ydescent, height)
2230
)
2331

2432
# Set the data of the image

0 commit comments

Comments
 (0)