-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add ruff config to pyproject.toml for devs who are interested #25147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5d471d6
a49b9d0
cff05d9
f19b57c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
ksunden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exclude = [ | ||
".git", | ||
"build", | ||
"doc/gallery", | ||
"doc/tutorials", | ||
"tools/gh_api.py", | ||
".tox", | ||
".eggs", | ||
] | ||
ignore = [ | ||
"D100", | ||
"D101", | ||
"D102", | ||
"D103", | ||
"D104", | ||
"D105", | ||
"D106", | ||
Comment on lines
+29
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused, these are in ignore, but also select. Do we want to just remove them altogether if we aren't going to use them? (ignore takes precedent) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, but that is how they are in the flake8 config, sooo??? My best guess is that that was originally put that way because those are rules we would like to enforce, but have too many failures to individually enumerate them yet. I ran Outside of that the handful of rules that are not currently supported by ruff are added to "external" (There may be cause to add to ignores later as well, didn't look too closely at those because they can't be configured as ignores yet anyway) It did not respect order of the per file ignores so I re-sorted them because that made it much easier to navigate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I tried it out, and selecting "D" was largely simply fine... Looking back at the flake8 config, it contains some comments which indicate that the select was all rules for the numpy convention. But then ignored are all the rules we break regularly. I already did configure it to use numpy style docstrings, which automatically disables several of the ignored rules (without having to specify) Thus selecting all "D" rules and only ignoring has the same effect, and cleans up the config quite a bit. Additionally, the following rules from the ignore list had only a single occurrence, so I may as well fix that occurrence and enforce the rule:
Additionally, selecting all pydocstyle ( There was a single occurrence of an empty docstring, in scale.py:LinearScale, which has a comment stating that the method is there explicitly to prevent inherited docstring.
The N error codes (enforcing naming conventions) that were included in the ignore list were also never selected (and selecting "N" was rather noisy even with the ignores). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think incrementally adding linter checks when appropriate is probably going to be easier, so this sounds fine to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I will state that the speed of ruff made this a lot better to test which rules could be enforced now... doing that with flake8 would have taken much much longer) |
||
"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"] |
Uh oh!
There was an error while loading. Please reload this page.