Skip to content

Commit faa3670

Browse files
authored
Merge pull request #30258 from QuLogic/ruff-update
Clean up mypy & ruff config
2 parents cfc366b + f4398bf commit faa3670

File tree

4 files changed

+21
-37
lines changed

4 files changed

+21
-37
lines changed

galleries/examples/ticks/date_formatters_locators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import matplotlib.pyplot as plt
1313
import numpy as np
1414

15+
# While these appear unused directly, they are used from eval'd strings.
1516
from matplotlib.dates import (FR, MO, MONTHLY, SA, SU, TH, TU, WE,
1617
AutoDateFormatter, AutoDateLocator,
1718
ConciseDateFormatter, DateFormatter, DayLocator,

galleries/tutorials/images.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
3434
In [1]: %matplotlib inline
3535
36-
This turns on inline plotting, where plot graphics will appear in your
37-
notebook. This has important implications for interactivity. For inline plotting, commands in
36+
This turns on inline plotting, where plot graphics will appear in your notebook. This
37+
has important implications for interactivity. For inline plotting, commands in
3838
cells below the cell that outputs a plot will not affect the plot. For example,
3939
changing the colormap is not possible from cells below the cell that creates a plot.
4040
However, for other backends, such as Qt, that open a separate window,

lib/matplotlib/backends/web_backend/nbagg_uat.ipynb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309
"metadata": {},
310310
"outputs": [],
311311
"source": [
312-
"from matplotlib.backends.backend_nbagg import new_figure_manager,show\n",
312+
"from matplotlib.backends.backend_nbagg import new_figure_manager\n",
313313
"\n",
314314
"manager = new_figure_manager(1000)\n",
315315
"fig = manager.canvas.figure\n",
@@ -341,15 +341,18 @@
341341
"x = np.arange(0, 2*np.pi, 0.01) # x-array\n",
342342
"line, = ax.plot(x, np.sin(x))\n",
343343
"\n",
344+
"\n",
344345
"def animate(i):\n",
345346
" line.set_ydata(np.sin(x+i/10.0)) # update the data\n",
346347
" return line,\n",
347348
"\n",
348-
"#Init only required for blitting to give a clean slate.\n",
349+
"\n",
350+
"# Init only required for blitting to give a clean slate.\n",
349351
"def init():\n",
350352
" line.set_ydata(np.ma.array(x, mask=True))\n",
351353
" return line,\n",
352354
"\n",
355+
"\n",
353356
"ani = animation.FuncAnimation(fig, animate, np.arange(1, 200), init_func=init,\n",
354357
" interval=100., blit=True)\n",
355358
"plt.show()"
@@ -405,6 +408,8 @@
405408
"ln, = ax.plot(x,y)\n",
406409
"evt = []\n",
407410
"colors = iter(itertools.cycle(['r', 'g', 'b', 'k', 'c']))\n",
411+
"\n",
412+
"\n",
408413
"def on_event(event):\n",
409414
" if event.name.startswith('key'):\n",
410415
" fig.suptitle('%s: %s' % (event.name, event.key))\n",
@@ -417,6 +422,7 @@
417422
" fig.canvas.draw()\n",
418423
" fig.canvas.draw_idle()\n",
419424
"\n",
425+
"\n",
420426
"fig.canvas.mpl_connect('button_press_event', on_event)\n",
421427
"fig.canvas.mpl_connect('button_release_event', on_event)\n",
422428
"fig.canvas.mpl_connect('scroll_event', on_event)\n",
@@ -448,10 +454,12 @@
448454
"fig, ax = plt.subplots()\n",
449455
"text = ax.text(0.5, 0.5, '', ha='center')\n",
450456
"\n",
457+
"\n",
451458
"def update(text):\n",
452459
" text.set(text=time.ctime())\n",
453460
" text.axes.figure.canvas.draw()\n",
454-
" \n",
461+
"\n",
462+
"\n",
455463
"timer = fig.canvas.new_timer(500, [(update, [text], {})])\n",
456464
"timer.start()\n",
457465
"plt.show()"
@@ -471,7 +479,7 @@
471479
"outputs": [],
472480
"source": [
473481
"fig, ax = plt.subplots()\n",
474-
"text = ax.text(0.5, 0.5, '', ha='center') \n",
482+
"text = ax.text(0.5, 0.5, '', ha='center')\n",
475483
"timer = fig.canvas.new_timer(500, [(update, [text], {})])\n",
476484
"\n",
477485
"timer.single_shot = True\n",
@@ -578,18 +586,20 @@
578586
"cnt = itertools.count()\n",
579587
"bg = None\n",
580588
"\n",
589+
"\n",
581590
"def onclick_handle(event):\n",
582591
" \"\"\"Should draw elevating green line on each mouse click\"\"\"\n",
583592
" global bg\n",
584593
" if bg is None:\n",
585-
" bg = ax.figure.canvas.copy_from_bbox(ax.bbox) \n",
594+
" bg = ax.figure.canvas.copy_from_bbox(ax.bbox)\n",
586595
" ax.figure.canvas.restore_region(bg)\n",
587596
"\n",
588597
" cur_y = (next(cnt) % 10) * 0.1\n",
589598
" ln.set_ydata([cur_y, cur_y])\n",
590599
" ax.draw_artist(ln)\n",
591600
" ax.figure.canvas.blit(ax.bbox)\n",
592601
"\n",
602+
"\n",
593603
"fig, ax = plt.subplots()\n",
594604
"ax.plot([0, 1], [0, 1], 'r')\n",
595605
"ln, = ax.plot([0, 1], [0, 0], 'g', animated=True)\n",
@@ -598,13 +608,6 @@
598608
"\n",
599609
"ax.figure.canvas.mpl_connect('button_press_event', onclick_handle)"
600610
]
601-
},
602-
{
603-
"cell_type": "code",
604-
"execution_count": null,
605-
"metadata": {},
606-
"outputs": [],
607-
"source": []
608611
}
609612
],
610613
"metadata": {

pyproject.toml

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,13 @@ sections = "FUTURE,STDLIB,THIRDPARTY,PYDATA,FIRSTPARTY,LOCALFOLDER"
9393
force_sort_within_sections = true
9494

9595
[tool.ruff]
96-
exclude = [
97-
".git",
96+
extend-exclude = [
9897
"build",
9998
"doc/gallery",
10099
"doc/tutorials",
101100
"tools/gh_api.py",
102-
".tox",
103-
".eggs",
104-
# TODO: fix .ipynb files
105-
"*.ipynb"
106101
]
107102
line-length = 88
108-
target-version = "py311"
109103

110104
[tool.ruff.lint]
111105
ignore = [
@@ -131,9 +125,7 @@ ignore = [
131125
"D404",
132126
"D413",
133127
"D415",
134-
"D416",
135128
"D417",
136-
"E24",
137129
"E266",
138130
"E305",
139131
"E306",
@@ -174,15 +166,13 @@ convention = "numpy"
174166

175167
[tool.ruff.lint.per-file-ignores]
176168
"*.pyi" = ["E501"]
169+
"*.ipynb" = ["E402"]
177170
"doc/conf.py" = ["E402"]
178-
"galleries/examples/animation/frame_grabbing_sgskip.py" = ["E402"]
179171
"galleries/examples/images_contours_and_fields/tricontour_demo.py" = ["E201"]
180172
"galleries/examples/images_contours_and_fields/tripcolor_demo.py" = ["E201"]
181173
"galleries/examples/images_contours_and_fields/triplot_demo.py" = ["E201"]
182174
"galleries/examples/lines_bars_and_markers/marker_reference.py" = ["E402"]
183-
"galleries/examples/misc/print_stdout_sgskip.py" = ["E402"]
184175
"galleries/examples/misc/table_demo.py" = ["E201"]
185-
"galleries/examples/style_sheets/bmh.py" = ["E501"]
186176
"galleries/examples/subplots_axes_and_figures/demo_constrained_layout.py" = ["E402"]
187177
"galleries/examples/text_labels_and_annotations/custom_legends.py" = ["E402"]
188178
"galleries/examples/ticks/date_concise_formatter.py" = ["E402"]
@@ -211,21 +201,17 @@ convention = "numpy"
211201
"lib/mpl_toolkits/axisartist/angle_helper.py" = ["E221"]
212202
"lib/mpl_toolkits/mplot3d/proj3d.py" = ["E201"]
213203

214-
"galleries/users_explain/artists/paths.py" = ["E402"]
215204
"galleries/users_explain/quick_start.py" = ["E402"]
216205
"galleries/users_explain/artists/patheffects_guide.py" = ["E402"]
217-
"galleries/users_explain/artists/transforms_tutorial.py" = ["E402", "E501"]
218-
"galleries/users_explain/colors/colormaps.py" = ["E501"]
206+
"galleries/users_explain/artists/transforms_tutorial.py" = ["E402"]
219207
"galleries/users_explain/colors/colors.py" = ["E402"]
220208
"galleries/tutorials/artists.py" = ["E402"]
221209
"galleries/users_explain/axes/constrainedlayout_guide.py" = ["E402"]
222210
"galleries/users_explain/axes/legend_guide.py" = ["E402"]
223211
"galleries/users_explain/axes/tight_layout_guide.py" = ["E402"]
224212
"galleries/users_explain/animations/animations.py" = ["E501"]
225-
"galleries/tutorials/images.py" = ["E501"]
226213
"galleries/tutorials/pyplot.py" = ["E402", "E501"]
227214
"galleries/users_explain/text/annotations.py" = ["E402", "E501"]
228-
"galleries/users_explain/text/mathtext.py" = ["E501"]
229215
"galleries/users_explain/text/text_intro.py" = ["E402"]
230216
"galleries/users_explain/text/text_props.py" = ["E501"]
231217

@@ -236,18 +222,12 @@ enable_error_code = [
236222
"redundant-expr",
237223
"truthy-bool",
238224
]
239-
enable_incomplete_feature = [
240-
"Unpack",
241-
]
242225
exclude = [
243226
#stubtest
244227
".*/matplotlib/(sphinxext|backends|pylab|testing/jpl_units)",
245228
#mypy precommit
246229
"galleries/",
247230
"doc/",
248-
"lib/matplotlib/backends/",
249-
"lib/matplotlib/sphinxext",
250-
"lib/matplotlib/testing/jpl_units",
251231
"lib/mpl_toolkits/",
252232
#removing tests causes errors in backends
253233
"lib/matplotlib/tests/",

0 commit comments

Comments
 (0)