Skip to content

Commit 5d471d6

Browse files
committed
Add ruff config to pyproject.toml for devs who are interested
The change to legend_handler was a numpydoc docstring with an errant black line after the Parameters section header. It was flagged by ruff (but not flake8), but I agree that it should be changed after reviewing numpydoc standards. Applying the `ruff --fix .` removed the blank line, and that was the only flagged error after converting the flake8 config to ruff config. While I was looking at the config, I realized that some of the E502 (line length) ignores were out of date since we bumped the line length to 88, so I removed those ignores from both configs. I did not change any files to adhere to the new limit, only removed ignores which failed the 79 limit but pass at 88. One note is that the flake8 config selects `C90` (mccabe complexity) but does not set a `max-complexity` value, meaning that the check is ignored. For ruff, a default complexity (10) is selected, and we have many methods which fail (our worst is 73 in sankey, but ~180 above 10). As such I removed it from the ruff config, rather than adding ignores, etc. At this time, I'm not enabling ruff on CI because it is missing 9 checks selected by flake8. Once those checks are implemented (or at least the more commonly applicable ones, not too worried about "semicolon at end of line", if I'm honest), may look to swap over because it is faster. (It already takes only ~1 minute for the linter CI to run most of the time, but if it it can get down to basically the startup/queue time, that would be just that little bit faster that you may see it before you context switch) All of the missing checks are from pycodestyle, but running pycodestyle outside of flake8 runs single threaded, so the wall clock time savings don't add up. Combined with the increased complexity of running more than one tool, not worth it to implement CI yet.
1 parent c9d7bff commit 5d471d6

File tree

3 files changed

+161
-7
lines changed

3 files changed

+161
-7
lines changed

.flake8

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ exclude =
4242
per-file-ignores =
4343
setup.py: E402
4444

45-
4645
lib/matplotlib/__init__.py: E402, F401
4746
lib/matplotlib/_animation_data.py: E501
4847
lib/matplotlib/_api/__init__.py: F401
@@ -81,9 +80,6 @@ per-file-ignores =
8180
tutorials/text/mathtext.py: E501
8281
tutorials/text/text_intro.py: E402
8382
tutorials/text/text_props.py: E501
84-
tutorials/text/usetex.py: E501
85-
tutorials/toolkits/axes_grid.py: E501
86-
tutorials/toolkits/axisartist.py: E501
8783

8884
examples/animation/frame_grabbing_sgskip.py: E402
8985
examples/images_contours_and_fields/tricontour_demo.py: E201
@@ -93,7 +89,6 @@ per-file-ignores =
9389
examples/misc/print_stdout_sgskip.py: E402
9490
examples/misc/table_demo.py: E201
9591
examples/style_sheets/bmh.py: E501
96-
examples/style_sheets/plot_solarizedlight2.py: E501
9792
examples/subplots_axes_and_figures/demo_constrained_layout.py: E402
9893
examples/text_labels_and_annotations/custom_legends.py: E402
9994
examples/ticks/date_concise_formatter.py: E402

lib/matplotlib/legend_handler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def __init__(self, xpad=0., ypad=0., update_func=None):
6363
"""
6464
Parameters
6565
----------
66-
6766
xpad : float, optional
6867
Padding in x-direction.
6968
ypad : float, optional

pyproject.toml

Lines changed: 161 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,171 @@ requires = [
77
"setuptools_scm>=7",
88
]
99

10-
1110
[tool.isort]
1211
known_mpltoolkits = "mpl_toolkits"
1312
known_pydata = "numpy, matplotlib.pyplot"
1413
known_firstparty = "matplotlib"
1514
sections = "FUTURE,STDLIB,THIRDPARTY,PYDATA,FIRSTPARTY,MPLTOOLKITS,LOCALFOLDER"
1615
no_lines_before = "MPLTOOLKITS"
1716
force_sort_within_sections = true
17+
18+
[tool.ruff]
19+
exclude = [
20+
".git",
21+
"build",
22+
"doc/gallery",
23+
"doc/tutorials",
24+
"tools/gh_api.py",
25+
".tox",
26+
".eggs",
27+
]
28+
ignore = [
29+
"D100",
30+
"D101",
31+
"D102",
32+
"D103",
33+
"D104",
34+
"D105",
35+
"D106",
36+
"D107",
37+
"D200",
38+
"D202",
39+
"D203",
40+
"D204",
41+
"D205",
42+
"D207",
43+
"D212",
44+
"D301",
45+
"D400",
46+
"D401",
47+
"D402",
48+
"D403",
49+
"D404",
50+
"D413",
51+
"E722",
52+
"E741",
53+
"F841",
54+
"N801",
55+
"N802",
56+
"N803",
57+
"N806",
58+
"N812",
59+
]
60+
line-length = 88
61+
select = [
62+
"D100",
63+
"D101",
64+
"D102",
65+
"D103",
66+
"D104",
67+
"D105",
68+
"D106",
69+
"D200",
70+
"D201",
71+
"D202",
72+
"D204",
73+
"D205",
74+
"D206",
75+
"D207",
76+
"D208",
77+
"D209",
78+
"D210",
79+
"D211",
80+
"D213",
81+
"D214",
82+
"D215",
83+
"D300",
84+
"D301",
85+
"D400",
86+
"D401",
87+
"D403",
88+
"D404",
89+
"D405",
90+
"D406",
91+
"D407",
92+
"D408",
93+
"D409",
94+
"D410",
95+
"D411",
96+
"D412",
97+
"D414",
98+
"E",
99+
"F",
100+
"W",
101+
]
102+
103+
# The following error codes are not supported by ruff v0.0.240
104+
# They are planned and should be selected once implemented
105+
# even if they are deselected by default.
106+
# These are primarily whitespace/corrected by autoformatters (which we don't use).
107+
# See https://github.com/charliermarsh/ruff/issues/2402 for status on implementation
108+
external = [
109+
"E122",
110+
"E201",
111+
"E202",
112+
"E203",
113+
"E221",
114+
"E251",
115+
"E261",
116+
"E272",
117+
"E302",
118+
"E703",
119+
]
120+
121+
target-version = "py39"
122+
123+
[tool.ruff.pydocstyle]
124+
convention = "numpy"
125+
126+
[tool.ruff.per-file-ignores]
127+
"setup.py" = ["E402"]
128+
129+
"doc/conf.py" = ["E402"]
130+
"examples/animation/frame_grabbing_sgskip.py" = ["E402"]
131+
"examples/lines_bars_and_markers/marker_reference.py" = ["E402"]
132+
"examples/misc/print_stdout_sgskip.py" = ["E402"]
133+
"examples/style_sheets/bmh.py" = ["E501"]
134+
"examples/subplots_axes_and_figures/demo_constrained_layout.py" = ["E402"]
135+
"examples/text_labels_and_annotations/custom_legends.py" = ["E402"]
136+
"examples/ticks/date_concise_formatter.py" = ["E402"]
137+
"examples/ticks/date_formatters_locators.py" = ["F401"]
138+
"examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py" = ["E402"]
139+
"examples/user_interfaces/embedding_in_gtk3_sgskip.py" = ["E402"]
140+
"examples/user_interfaces/embedding_in_gtk4_panzoom_sgskip.py" = ["E402"]
141+
"examples/user_interfaces/embedding_in_gtk4_sgskip.py" = ["E402"]
142+
"examples/user_interfaces/gtk3_spreadsheet_sgskip.py" = ["E402"]
143+
"examples/user_interfaces/gtk4_spreadsheet_sgskip.py" = ["E402"]
144+
"examples/user_interfaces/mpl_with_glade3_sgskip.py" = ["E402"]
145+
"examples/user_interfaces/pylab_with_gtk3_sgskip.py" = ["E402"]
146+
"examples/user_interfaces/pylab_with_gtk4_sgskip.py" = ["E402"]
147+
"examples/userdemo/pgf_preamble_sgskip.py" = ["E402"]
148+
149+
"lib/matplotlib/__init__.py" = ["E402", "F401"]
150+
"lib/matplotlib/_animation_data.py" = ["E501"]
151+
"lib/matplotlib/_api/__init__.py" = ["F401"]
152+
"lib/matplotlib/axes/__init__.py" = ["F401", "F403"]
153+
"lib/matplotlib/backends/backend_template.py" = ["F401"]
154+
"lib/matplotlib/font_manager.py" = ["E501"]
155+
"lib/matplotlib/image.py" = ["F401", "F403"]
156+
"lib/matplotlib/pylab.py" = ["F401", "F403"]
157+
"lib/matplotlib/pyplot.py" = ["F401", "F811"]
158+
"lib/matplotlib/tests/test_mathtext.py" = ["E501"]
159+
"lib/mpl_toolkits/axisartist/__init__.py" = ["F401"]
160+
"lib/pylab.py" = ["F401", "F403"]
161+
162+
"tutorials/advanced/path_tutorial.py" = ["E402"]
163+
"tutorials/advanced/patheffects_guide.py" = ["E402"]
164+
"tutorials/advanced/transforms_tutorial.py" = ["E402", "E501"]
165+
"tutorials/colors/colormaps.py" = ["E501"]
166+
"tutorials/colors/colors.py" = ["E402"]
167+
"tutorials/intermediate/artists.py" = ["E402"]
168+
"tutorials/intermediate/constrainedlayout_guide.py" = ["E402"]
169+
"tutorials/intermediate/legend_guide.py" = ["E402"]
170+
"tutorials/intermediate/tight_layout_guide.py" = ["E402"]
171+
"tutorials/introductory/animation_tutorial.py" = ["E501"]
172+
"tutorials/introductory/images.py" = ["E501"]
173+
"tutorials/introductory/pyplot.py" = ["E402", "E501"]
174+
"tutorials/text/annotations.py" = ["E402", "E501"]
175+
"tutorials/text/mathtext.py" = ["E501"]
176+
"tutorials/text/text_intro.py" = ["E402"]
177+
"tutorials/text/text_props.py" = ["E501"]

0 commit comments

Comments
 (0)