Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ca3491

Browse files
committed
Enable ruff's preview whitespace linting rules
These are the ones we were using with flake8, but were not available before ruff 0.2.0 (or at least whatever the last tested version was). Also, clean up a bit of the code so that we only use one type of whitespace exception.
1 parent c0c4f6a commit 7ca3491

File tree

5 files changed

+54
-38
lines changed

5 files changed

+54
-38
lines changed

.flake8

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ exclude =
3434

3535
per-file-ignores =
3636
lib/matplotlib/_cm.py: E202, E203, E302
37-
lib/matplotlib/_mathtext.py: E221, E251
38-
lib/matplotlib/_mathtext_data.py: E203, E261
37+
lib/matplotlib/_mathtext.py: E221
38+
lib/matplotlib/_mathtext_data.py: E203
3939
lib/matplotlib/backends/backend_template.py: F401
4040
lib/matplotlib/mathtext.py: E221
4141
lib/matplotlib/pylab.py: F401, F403
4242
lib/matplotlib/pyplot.py: F811
4343
lib/matplotlib/tests/test_mathtext.py: E501
44-
lib/matplotlib/transforms.py: E201, E202, E203
44+
lib/matplotlib/transforms.py: E201, E202
4545
lib/matplotlib/tri/_triinterpolate.py: E201, E221
4646
lib/mpl_toolkits/axes_grid1/axes_size.py: E272
4747
lib/mpl_toolkits/axisartist/angle_helper.py: E221
48+
lib/mpl_toolkits/mplot3d/proj3d.py: E201
4849

4950
doc/conf.py: E402
5051
galleries/users_explain/quick_start.py: E402

lib/matplotlib/_mathtext.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -379,27 +379,27 @@ def _get_info(self, fontname: str, font_class: str, sym: str, fontsize: float,
379379
xmin, ymin, xmax, ymax = [val/64.0 for val in glyph.bbox]
380380
offset = self._get_offset(font, glyph, fontsize, dpi)
381381
metrics = FontMetrics(
382-
advance = glyph.linearHoriAdvance/65536.0,
383-
height = glyph.height/64.0,
384-
width = glyph.width/64.0,
385-
xmin = xmin,
386-
xmax = xmax,
387-
ymin = ymin+offset,
388-
ymax = ymax+offset,
382+
advance=glyph.linearHoriAdvance / 65536,
383+
height=glyph.height / 64,
384+
width=glyph.width / 64,
385+
xmin=xmin,
386+
xmax=xmax,
387+
ymin=ymin + offset,
388+
ymax=ymax + offset,
389389
# iceberg is the equivalent of TeX's "height"
390-
iceberg = glyph.horiBearingY/64.0 + offset,
391-
slanted = slanted
392-
)
390+
iceberg=glyph.horiBearingY / 64 + offset,
391+
slanted=slanted
392+
)
393393

394394
return FontInfo(
395-
font = font,
396-
fontsize = fontsize,
397-
postscript_name = font.postscript_name,
398-
metrics = metrics,
399-
num = num,
400-
glyph = glyph,
401-
offset = offset
402-
)
395+
font=font,
396+
fontsize=fontsize,
397+
postscript_name=font.postscript_name,
398+
metrics=metrics,
399+
num=num,
400+
glyph=glyph,
401+
offset=offset
402+
)
403403

404404
def get_xheight(self, fontname: str, fontsize: float, dpi: float) -> float:
405405
font = self._get_font(fontname)

lib/matplotlib/transforms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,9 +2574,9 @@ def get_matrix(self):
25742574
if DEBUG and (x_scale == 0 or y_scale == 0):
25752575
raise ValueError(
25762576
"Transforming from or to a singular bounding box")
2577-
self._mtx = np.array([[x_scale, 0.0 , (-inl*x_scale+outl)],
2578-
[0.0 , y_scale, (-inb*y_scale+outb)],
2579-
[0.0 , 0.0 , 1.0 ]],
2577+
self._mtx = np.array([[x_scale, 0.0, -inl*x_scale+outl],
2578+
[ 0.0, y_scale, -inb*y_scale+outb],
2579+
[ 0.0, 0.0, 1.0]],
25802580
float)
25812581
self._inverted = None
25822582
self._invalid = 0
@@ -2668,9 +2668,9 @@ def get_matrix(self):
26682668
raise ValueError("Transforming from a singular bounding box.")
26692669
x_scale = 1.0 / inw
26702670
y_scale = 1.0 / inh
2671-
self._mtx = np.array([[x_scale, 0.0 , (-inl*x_scale)],
2672-
[0.0 , y_scale, (-inb*y_scale)],
2673-
[0.0 , 0.0 , 1.0 ]],
2671+
self._mtx = np.array([[x_scale, 0.0, -inl*x_scale],
2672+
[ 0.0, y_scale, -inb*y_scale],
2673+
[ 0.0, 0.0, 1.0]],
26742674
float)
26752675
self._inverted = None
26762676
self._invalid = 0

lib/mpl_toolkits/mplot3d/proj3d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def world_transformation(xmin, xmax,
2323
dy /= ay
2424
dz /= az
2525

26-
return np.array([[1/dx, 0, 0, -xmin/dx],
27-
[0, 1/dy, 0, -ymin/dy],
28-
[0, 0, 1/dz, -zmin/dz],
29-
[0, 0, 0, 1]])
26+
return np.array([[1/dx, 0, 0, -xmin/dx],
27+
[ 0, 1/dy, 0, -ymin/dy],
28+
[ 0, 0, 1/dz, -zmin/dz],
29+
[ 0, 0, 0, 1]])
3030

3131

3232
@_api.deprecated("3.8")

pyproject.toml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,21 @@ ignore = [
136136
"E741",
137137
"F841",
138138
]
139+
preview = true
140+
explicit-preview-rules = true
139141
select = [
140142
"D",
141143
"E",
142144
"F",
143145
"W",
146+
# The following error codes require the preview mode to be enabled.
147+
"E201",
148+
"E202",
149+
"E203",
150+
"E221",
151+
"E251",
152+
"E261",
153+
"E272",
144154
]
145155

146156
# The following error codes are not supported by ruff v0.2.0
@@ -150,13 +160,6 @@ select = [
150160
# See https://github.com/charliermarsh/ruff/issues/2402 for status on implementation
151161
external = [
152162
"E122",
153-
"E201",
154-
"E202",
155-
"E203",
156-
"E221",
157-
"E251",
158-
"E261",
159-
"E272",
160163
"E302",
161164
"E703",
162165
]
@@ -167,8 +170,12 @@ convention = "numpy"
167170
[tool.ruff.lint.per-file-ignores]
168171
"doc/conf.py" = ["E402"]
169172
"galleries/examples/animation/frame_grabbing_sgskip.py" = ["E402"]
173+
"galleries/examples/images_contours_and_fields/tricontour_demo.py" = ["E201"]
174+
"galleries/examples/images_contours_and_fields/tripcolor_demo.py" = ["E201"]
175+
"galleries/examples/images_contours_and_fields/triplot_demo.py" = ["E201"]
170176
"galleries/examples/lines_bars_and_markers/marker_reference.py" = ["E402"]
171177
"galleries/examples/misc/print_stdout_sgskip.py" = ["E402"]
178+
"galleries/examples/misc/table_demo.py" = ["E201"]
172179
"galleries/examples/style_sheets/bmh.py" = ["E501"]
173180
"galleries/examples/subplots_axes_and_figures/demo_constrained_layout.py" = ["E402"]
174181
"galleries/examples/text_labels_and_annotations/custom_legends.py" = ["E402"]
@@ -188,14 +195,22 @@ convention = "numpy"
188195
"lib/matplotlib/__init__.py" = ["E402", "F401"]
189196
"lib/matplotlib/_animation_data.py" = ["E501"]
190197
"lib/matplotlib/_api/__init__.py" = ["F401"]
198+
"lib/matplotlib/_cm.py" = ["E202", "E203"]
199+
"lib/matplotlib/_mathtext.py" = ["E221"]
200+
"lib/matplotlib/_mathtext_data.py" = ["E203"]
191201
"lib/matplotlib/axes/__init__.py" = ["F401", "F403"]
192202
"lib/matplotlib/backends/backend_template.py" = ["F401"]
193203
"lib/matplotlib/font_manager.py" = ["E501"]
194204
"lib/matplotlib/image.py" = ["F401", "F403"]
195205
"lib/matplotlib/pylab.py" = ["F401", "F403"]
196206
"lib/matplotlib/pyplot.py" = ["F401", "F811"]
197207
"lib/matplotlib/tests/test_mathtext.py" = ["E501"]
208+
"lib/matplotlib/transforms.py" = ["E201"]
209+
"lib/matplotlib/tri/_triinterpolate.py" = ["E201", "E221"]
210+
"lib/mpl_toolkits/axes_grid1/axes_size.py" = ["E272"]
198211
"lib/mpl_toolkits/axisartist/__init__.py" = ["F401"]
212+
"lib/mpl_toolkits/axisartist/angle_helper.py" = ["E221"]
213+
"lib/mpl_toolkits/mplot3d/proj3d.py" = ["E201"]
199214
"lib/pylab.py" = ["F401", "F403"]
200215

201216
"galleries/users_explain/artists/paths.py" = ["E402"]

0 commit comments

Comments
 (0)