10000 Merge pull request #23494 from QuLogic/sonarqube-fixes · oscargus/matplotlib@b5ac96a · GitHub
[go: up one dir, main page]

Skip to content

Commit b5ac96a

Browse files
authored
Merge pull request matplotlib#23494 from QuLogic/sonarqube-fixes
MNT: Fix various issues from SonarQube
2 parents 5d0d141 + a9ec6aa commit b5ac96a

34 files changed

+57
-94
lines changed

doc/sphinxext/redirect_from.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ class RedirectFrom(Directive):
9191
def run(self):
9292
redirected_doc, = self.arguments
9393
env = self.app.env
94-
builder = self.app.builder
9594
domain = env.get_domain('redirect_from')
9695
current_doc = env.path2doc(self.state.document.current_source)
9796
redirected_reldoc, _ = env.relfn2path(redirected_doc, current_doc)

examples/event_handling/coords_demo.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@
2727

2828
def on_move(event):
2929
if event.inaxes:
30-
# get the x and y pixel coords
31-
x, y = event.x, event.y
32-
ax = event.inaxes # the axes instance
33-
print('data coords %f %f, pixel coords %f %f'
34-
% (event.xdata, event.ydata, x, y))
30+
print(f'data coords {event.xdata} {event.ydata},',
31+
f'pixel coords {event.x} {event.y}')
3532

3633

3734
def on_click(event):

examples/event_handling/pick_event_demo2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
17AE @@ -34,11 +34,11 @@
3434
def onpick(event):
3535

3636
if event.artist != line:
37-
return True
37+
return
3838

3939
N = len(event.ind)
4040
if not N:
41-
return True
41+
return
4242

4343
figi, axs = plt.subplots(N, squeeze=False)
4444
for ax, dataind in zip(axs.flat, event.ind):
@@ -47,7 +47,7 @@ def onpick(event):
4747
transform=ax.transAxes, va='top')
4848
ax.set_ylim(-0.5, 1.5)
4949
figi.show()
50-
return True
50+
5151

5252
fig.canvas.mpl_connect('pick_event', onpick)
5353

examples/event_handling/pong_sgskip.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def __init__(self, ax):
190190
animated=False)
191191
self.canvas.mpl_connect('key_press_event', self.on_key_press)
192192

193-
def draw(self, event):
193+
def draw(self):
194194
draw_artist = self.ax.draw_artist
195195
if self.background is None:
196196
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
@@ -231,7 +231,7 @@ def draw(self, event):
231231

232232
self.background = None
233233
self.ax.figure.canvas.draw_idle()
234-
return True
234+
return
235235
puck.disp.set_offsets([[puck.x, puck.y]])
236236
self.ax.draw_artist(puck.disp)
237237

@@ -244,7 +244,6 @@ def draw(self, event):
244244
plt.close()
245245

246246
self.cnt += 1
247-
return True
248247

249248
def on_key_press(self, event):
250249
if event.key == '3':
@@ -317,10 +316,7 @@ def on_redraw(event):
317316
def start_anim(event):
318317
canvas.mpl_disconnect(start_anim.cid)
319318

320-
def local_draw():
321-
if animation.ax.get_renderer_cache():
322-
animation.draw(None)
323-
start_anim.timer.add_callback(local_draw)
319+
start_anim.timer.add_callback(animation.draw)
324320
start_anim.timer.start()
325321
canvas.mpl_connect('draw_event', on_redraw)
326322

examples/misc/demo_agg_filter.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BaseFilter:
3838
def get_pad(self, dpi):
3939
return 0
4040

41-
def process_image(padded_src, dpi):
41+
def process_image(self, padded_src, dpi):
4242
raise NotImplementedError("Should be overridden by subclasses")
4343

4444
def __call__(self, im, dpi):
@@ -233,20 +233,19 @@ def drop_shadow_line(ax):
233233
def drop_shadow_patches(ax):
234234
# Copied from barchart_demo.py
235235
N = 5
236-
men_means = [20, 35, 30, 35, 27]
236+
group1_means = [20, 35, 30, 35, 27]
237237

238238
ind = np.arange(N) # the x locations for the groups
239239
width = 0.35 # the width of the bars
240240

241-
rects1 = ax.bar(ind, men_means, width, color='r', ec="w", lw=2)
241+
rects1 = ax.bar(ind, group1_means, width, color='r', ec="w", lw=2)
242242

243-
women_means = [25, 32, 34, 20, 25]
244-
rects2 = ax.bar(ind + width + 0.1, women_means, width,
243+
group2_means = [25, 32, 34, 20, 25]
244+
rects2 = ax.bar(ind + width + 0.1, group2_means, width,
245245
color='y', ec="w", lw=2)
246246

247-
# gauss = GaussianFilter(1.5, offsets=(1, 1))
248-
gauss = DropShadowFilter(5, offsets=(1, 1))
249-
shadow = FilteredArtistList(rects1 + rects2, gauss)
247+
drop = DropShadowFilter(5, offsets=(1, 1))
248+
shadow = FilteredArtistList(rects1 + rects2, drop)
250249
ax.add_artist(shadow)
251250
shadow.set_zorder(rects1[0].get_zorder() - 0.1)
252251

examples/misc/hyperlinks_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
fig = plt.figure()
2020
s = plt.scatter([1, 2, 3], [4, 5, 6])
21-
s.set_urls(['https://www.bbc.co.uk/news', 'https://www.google.com/', None])
21+
s.set_urls(['https://www.bbc.com/news', 'https://www.google.com/', None])
2222
fig.savefig('scatter.svg')
2323

2424
###############################################################################

examples/subplots_axes_and_figures/axes_zoom_effect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def connect_bbox(bbox1, bbox2,
3232
bbox_patch2 = BboxPatch(bbox2, **prop_patches)
3333

3434
p = BboxConnectorPatch(bbox1, bbox2,
35-
# loc1a=3, loc2a=2, loc1b=4, loc2b=1,
3635
loc1a=loc1a, loc2a=loc2a, loc1b=loc1b, loc2b=loc2b,
3736
clip_on=False,
3837
**prop_patches)

examples/text_labels_and_annotations/annotation_demo.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@
249249
xy=(2., -1), xycoords='data',
250250
xytext=(-100, 60), textcoords='offset points',
251251
size=20,
252-
# bbox=dict(boxstyle="round", fc="0.8"),
253252
arrowprops=dict(arrowstyle="fancy",
254253
fc="0.6", ec="none",
255254
patchB=el,
@@ -258,7 +257,6 @@
258257
xy=(2., -1), xycoords='data',
259258
xytext=(100, 60), textcoords='offset points',
260259
size=20,
261-
# bbox=dict(boxstyle="round", fc="0.8"),
262260
arrowprops=dict(arrowstyle="simple",
263261
fc="0.6", ec="none",
264262
patchB=el,
@@ -267,7 +265,6 @@
267265
xy=(2., -1), xycoords='data',
268266
xytext=(-100, -100), textcoords='offset points',
269267
size=20,
270-
# bbox=dict(boxstyle="round", fc="0.8"),
271268
arrowprops=dict(arrowstyle="wedge,tail_width=0.7",
272269
fc="0.6", ec="none",
273270
patchB=el,

examples/text_labels_and_annotations/arrow_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def make_arrow_graph(ax, data, size=4, display='length', shape='right',
116116
fc=fc, ec=ec or fc, alpha=alpha, width=width,
117117
head_width=head_width, head_length=head_length, shape=shape,
118118
length_includes_head=True,
119+
**kwargs
119120
)
120121

121122
# figure out coordinates for text:

lib/matplotlib/_docstring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def some_function(x):
3333
def __init__(self, *args, **kwargs):
3434
if args and kwargs:
3535
raise TypeError("Only positional or keyword args are allowed")
36-
self.params = params = args or kwargs
36+
self.params = args or kwargs
3737

3838
def __call__(self, func):
3939
if func.__doc__:

0 commit comments

Comments
 (0)
0