Skip to content

Commit

Permalink
Merge pull request matplotlib#25147 from ksunden/ruff_config
Browse files Browse the repository at this point in the history
Add ruff config to pyproject.toml for devs who are interested
  • Loading branch information
tacaswell committed Feb 22, 2023
2 parents eeef80f + f19b57c commit f9de8aa
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 28 deletions.
28 changes: 7 additions & 21 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,23 @@
max-line-length = 88
select =
# flake8 default
C90, E, F, W,
# docstring-convention=numpy
D100, D101, D102, D103, D104, D105, D106,
D200, D201, D202, D204, D205, D206, D207, D208,
D209, D210, D211, D214, D215,
D300, D301, D302,
D400, D401, D403, D404, D405, D406, D407, D408,
D409, D410, D411, D412, D414,
# matplotlib-specific extra pydocstyle errors
D213,
D, E, F, W,
ignore =
# flake8 default
E121,E123,E126,E226,E24,E704,W503,W504,
# Additional ignores:
E127, E131,
E266,
E305, E306,
E722, E741,
E741,
F841,
# Some new flake8 ignores:
N801, N802, N803, N806, N812,
# pydocstyle
D100, D101, D102, D103, D104, D105, D106, D107,
D200, D202, D203, D204, D205, D207, D212,
D100, D101, D102, D103, D104, D105, D106,
D200, D202, D204, D205,
D301,
D400, D401, D402, D403, D404, D413,
D400, D401, D403, D404
# ignored by pydocstyle numpy docstring convention
D107, D203, D212, D213, D402, D413, D415, D416, D417,

exclude =
.git
Expand All @@ -42,7 +33,6 @@ exclude =
per-file-ignores =
setup.py: E402


lib/matplotlib/__init__.py: E402, F401
lib/matplotlib/_animation_data.py: E501
lib/matplotlib/_api/__init__.py: F401
Expand Down Expand Up @@ -81,9 +71,6 @@ per-file-ignores =
tutorials/text/mathtext.py: E501
tutorials/text/text_intro.py: E402
tutorials/text/text_props.py: E501
tutorials/text/usetex.py: E501
tutorials/toolkits/axes_grid.py: E501
tutorials/toolkits/axisartist.py: E501

examples/animation/frame_grabbing_sgskip.py: E402
examples/images_contours_and_fields/tricontour_demo.py: E201
Expand All @@ -93,7 +80,6 @@ per-file-ignores =
examples/misc/print_stdout_sgskip.py: E402
examples/misc/table_demo.py: E201
examples/style_sheets/bmh.py: E501
examples/style_sheets/plot_solarizedlight2.py: E501
examples/subplots_axes_and_figures/demo_constrained_layout.py: E402
examples/text_labels_and_annotations/custom_legends.py: E402
examples/ticks/date_concise_formatter.py: E402
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/legend_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def __init__(self, xpad=0., ypad=0., update_func=None):
"""
Parameters
----------
xpad : float, optional
Padding in x-direction.
ypad : float, optional
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(self, axis):
# constructor docstring, which would otherwise end up interpolated into
# the docstring of Axis.set_scale.
"""
"""
""" # noqa: D419

def set_default_locators_and_formatters(self, axis):
# docstring inherited
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_backend_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_sigint(target, kwargs):
try:
proc.wait_for('DRAW')
stdout, _ = proc.communicate(timeout=_test_timeout)
except:
except Exception:
proc.kill()
stdout, _ = proc.communicate()
raise
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_other_signal_before_sigint(target, kwargs):
proc.wait_for('SIGUSR1')
os.kill(proc.pid, signal.SIGINT)
stdout, _ = proc.communicate(timeout=_test_timeout)
except:
except Exception:
proc.kill()
stdout, _ = proc.communicate()
raise
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def test_get_font_names():
font = ft2font.FT2Font(path)
prop = ttfFontProperty(font)
ttf_fonts.append(prop.name)
except:
except Exception:
pass
available_fonts = sorted(list(set(ttf_fonts)))
mpl_font_names = sorted(fontManager.get_font_names())
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Text3D(mtext.Text):
----------------
**kwargs
All other parameters are passed on to `~matplotlib.text.Text`.
"""
"""

def __init__(self, x=0, y=0, z=0, text='', zdir='z', **kwargs):
mtext.Text.__init__(self, x, y, text, **kwargs)
Expand Down
115 changes: 114 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,124 @@ requires = [
"setuptools_scm>=7",
]


[tool.isort]
known_mpltoolkits = "mpl_toolkits"
known_pydata = "numpy, matplotlib.pyplot"
known_firstparty = "matplotlib"
sections = "FUTURE,STDLIB,THIRDPARTY,PYDATA,FIRSTPARTY,MPLTOOLKITS,LOCALFOLDER"
no_lines_before = "MPLTOOLKITS"
force_sort_within_sections = true

[tool.ruff]
exclude = [
".git",
"build",
"doc/gallery",
"doc/tutorials",
"tools/gh_api.py",
".tox",
".eggs",
]
ignore = [
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D200",
"D202",
"D204",
"D205",
"D301",
"D400",
"D401",
"D403",
"D404",
"E741",
"F841",
]
line-length = 88
select = [
"D",
"E",
"F",
"W",
]

# The following error codes are not supported by ruff v0.0.240
# They are planned and should be selected once implemented
# even if they are deselected by default.
# These are primarily whitespace/corrected by autoformatters (which we don't use).
# See https://github.com/charliermarsh/ruff/issues/2402 for status on implementation
external = [
"E122",
"E201",
"E202",
"E203",
"E221",
"E251",
"E261",
"E272",
"E302",
"E703",
]

target-version = "py39"

[tool.ruff.pydocstyle]
convention = "numpy"

[tool.ruff.per-file-ignores]
"setup.py" = ["E402"]

"doc/conf.py" = ["E402"]
"examples/animation/frame_grabbing_sgskip.py" = ["E402"]
"examples/lines_bars_and_markers/marker_reference.py" = ["E402"]
"examples/misc/print_stdout_sgskip.py" = ["E402"]
"examples/style_sheets/bmh.py" = ["E501"]
"examples/subplots_axes_and_figures/demo_constrained_layout.py" = ["E402"]
"examples/text_labels_and_annotations/custom_legends.py" = ["E402"]
"examples/ticks/date_concise_formatter.py" = ["E402"]
"examples/ticks/date_formatters_locators.py" = ["F401"]
"examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py" = ["E402"]
"examples/user_interfaces/embedding_in_gtk3_sgskip.py" = ["E402"]
"examples/user_interfaces/embedding_in_gtk4_panzoom_sgskip.py" = ["E402"]
"examples/user_interfaces/embedding_in_gtk4_sgskip.py" = ["E402"]
"examples/user_interfaces/gtk3_spreadsheet_sgskip.py" = ["E402"]
"examples/user_interfaces/gtk4_spreadsheet_sgskip.py" = ["E402"]
"examples/user_interfaces/mpl_with_glade3_sgskip.py" = ["E402"]
"examples/user_interfaces/pylab_with_gtk3_sgskip.py" = ["E402"]
"examples/user_interfaces/pylab_with_gtk4_sgskip.py" = ["E402"]
"examples/userdemo/pgf_preamble_sgskip.py" = ["E402"]

"lib/matplotlib/__init__.py" = ["E402", "F401"]
"lib/matplotlib/_animation_data.py" = ["E501"]
"lib/matplotlib/_api/__init__.py" = ["F401"]
"lib/matplotlib/axes/__init__.py" = ["F401", "F403"]
"lib/matplotlib/backends/backend_template.py" = ["F401"]
"lib/matplotlib/font_manager.py" = ["E501"]
"lib/matplotlib/image.py" = ["F401", "F403"]
"lib/matplotlib/pylab.py" = ["F401", "F403"]
"lib/matplotlib/pyplot.py" = ["F401", "F811"]
"lib/matplotlib/tests/test_mathtext.py" = ["E501"]
"lib/mpl_toolkits/axisartist/__init__.py" = ["F401"]
"lib/pylab.py" = ["F401", "F403"]

"tutorials/advanced/path_tutorial.py" = ["E402"]
"tutorials/advanced/patheffects_guide.py" = ["E402"]
"tutorials/advanced/transforms_tutorial.py" = ["E402", "E501"]
"tutorials/colors/colormaps.py" = ["E501"]
"tutorials/colors/colors.py" = ["E402"]
"tutorials/intermediate/artists.py" = ["E402"]
"tutorials/intermediate/constrainedlayout_guide.py" = ["E402"]
"tutorials/intermediate/legend_guide.py" = ["E402"]
"tutorials/intermediate/tight_layout_guide.py" = ["E402"]
"tutorials/introductory/animation_tutorial.py" = ["E501"]
"tutorials/introductory/images.py" = ["E501"]
"tutorials/introductory/pyplot.py" = ["E402", "E501"]
"tutorials/text/annotations.py" = ["E402", "E501"]
"tutorials/text/mathtext.py" = ["E501"]
"tutorials/text/text_intro.py" = ["E402"]
"tutorials/text/text_props.py" = ["E501"]

0 comments on commit f9de8aa

Please sign in to comment.