-
Notifications
You must be signed in to change notification settings - Fork 224
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
Replace flakeheaven and isort with ruff #2747
Changes from 3 commits
451cb61
ece0730
03e0357
a208ca8
b369811
ead3abe
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 |
---|---|---|
|
@@ -85,27 +85,30 @@ make-summary-multi-line = true | |
wrap-summaries = 79 | ||
wrap-descriptions = 79 | ||
|
||
[tool.flakeheaven] | ||
max_line_length = 88 | ||
max_doc_length = 79 | ||
show_source = true | ||
[tool.ruff] | ||
line-length = 88 # E501 (line-too-long) | ||
show-source = true | ||
select = [ | ||
"E", # pycodestyle | ||
"F", # pyflakes | ||
"I", # isort | ||
"W", # pycodestyle warnings | ||
] | ||
ignore = ["E501"] # Avoid enforcing line-length violations | ||
Comment on lines
-88
to
+97
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. Previously with pygmt/helpers/decorators.py:206:89: E501 Line too long (98 > 88 characters)
|
204 | "interpolation": r"""
205 | interpolation : str
206 | [**b**\|\ **c**\|\ **l**\|\ **n**][**+a**][**+b**\ *BC*][**+c**][**+t**\ *threshold*].
| ^^^^^^^^^^ E501
207 | Select interpolation mode for grids. You can select the type of
208 | spline used:
| Note that So what should we do in this case? 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. Can we ignore both For long URLs, we can either add
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 considering that we replace
E501 is ignored already right now. We could ignore 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.
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.
Sounds good 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. Hmm actually, I just did some tesitng and maybe we shouldn't ignore
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. https://docs.astral.sh/ruff/rules/doc-line-too-long/#why-is-this-bad
I think it means that we can simply remove all 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.
Tried removing all the ruff check pygmt doc/conf.py examples
pygmt/datasets/earth_age.py:75:80: W505 Doc line too long (133 > 79 characters)
|
73 | (i.e., ``grid.gmt.registration`` and ``grid.gmt.gtype`` respectively).
74 | However, these properties may be lost after specific grid operations (such
75 | as slicing) and will need to be manually set before passing the grid to any PyGMT data processing or plotting functions. Refer to
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
76 | :class:`pygmt.GMTDataArrayAccessor` for detailed explanations and
77 | workarounds.
|
pygmt/datasets/samples.py:334:80: W505 Doc line too long (80 > 79 characters)
|
332 | >>> # use list_sample_data to see the available datasets
333 | >>> pprint(list_sample_data(), width=120)
334 | {'bathymetry': 'Table of ship bathymetric observations off Baja California',
| ^ W505
335 | 'earth_relief_holes': 'Regional 20 arc-minutes Earth relief grid with holes',
336 | 'fractures': 'Table of hypothetical fracture lengths and azimuths',
|
pygmt/datasets/samples.py:335:80: W505 Doc line too long (82 > 79 characters)
|
333 | >>> pprint(list_sample_data(), width=120)
334 | {'bathymetry': 'Table of ship bathymetric observations off Baja California',
335 | 'earth_relief_holes': 'Regional 20 arc-minutes Earth relief grid with holes',
| ^^^ W505
336 | 'fractures': 'Table of hypothetical fracture lengths and azimuths',
337 | 'hotspots': 'Table of locations, names, and symbol sizes of hotpots from Müller et al. (1993)',
|
pygmt/datasets/samples.py:337:80: W505 Doc line too long (100 > 79 characters)
|
335 | 'earth_relief_holes': 'Regional 20 arc-minutes Earth relief grid with holes',
336 | 'fractures': 'Table of hypothetical fracture lengths and azimuths',
337 | 'hotspots': 'Table of locations, names, and symbol sizes of hotpots from Müller et al. (1993)',
| ^^^^^^^^^^^^^^^^^^^^^ W505
338 | 'japan_quakes': 'Table of earthquakes around Japan from the NOAA NGDC database',
339 | 'mars_shape': 'Table of topographic signature of the hemispheric dichotomy of Mars from Smith and Zuber (1996)',
|
pygmt/datasets/samples.py:338:80: W505 Doc line too long (85 > 79 characters)
|
336 | 'fractures': 'Table of hypothetical fracture lengths and azimuths',
337 | 'hotspots': 'Table of locations, names, and symbol sizes of hotpots from Müller et al. (1993)',
338 | 'japan_quakes': 'Table of earthquakes around Japan from the NOAA NGDC database',
| ^^^^^^ W505
make: *** [Makefile:72: check] Error 1
339 | 'mars_shape': 'Table of topographic signature of the hemispheric dichotomy of Mars from Smith and Zuber (1996)',
340 | 'maunaloa_co2': 'Table of CO2 readings from Mauna Loa',
|
pygmt/datasets/samples.py:339:80: W505 Doc line too long (117 > 79 characters)
|
337 | 'hotspots': 'Table of locations, names, and symbol sizes of hotpots from Müller et al. (1993)',
338 | 'japan_quakes': 'Table of earthquakes around Japan from the NOAA NGDC database',
339 | 'mars_shape': 'Table of topographic signature of the hemispheric dichotomy of Mars from Smith and Zuber (1996)',
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
340 | 'maunaloa_co2': 'Table of CO2 readings from Mauna Loa',
341 | 'notre_dame_topography': 'Table 5.11 in Davis: Statistics and Data Analysis in Geology',
|
pygmt/datasets/samples.py:341:80: W505 Doc line too long (93 > 79 characters)
|
339 | 'mars_shape': 'Table of topographic signature of the hemispheric dichotomy of Mars from Smith and Zuber (1996)',
340 | 'maunaloa_co2': 'Table of CO2 readings from Mauna Loa',
341 | 'notre_dame_topography': 'Table 5.11 in Davis: Statistics and Data Analysis in Geology',
| ^^^^^^^^^^^^^^ W505
342 | 'ocean_ridge_points': 'Table of ocean ridge points for the entire world',
343 | 'rock_compositions': 'Table of rock sample compositions',
|
pygmt/src/nearneighbor.py:43:80: W505 Doc line too long (80 > 79 characters)
|
41 | Grid table data using a "Nearest neighbor" algorithm.
42 |
43 | **nearneighbor** reads arbitrarily located (*x*, *y*, *z*\ [, *w*]) triplets
| ^ W505
44 | [quadruplets] and uses a nearest neighbor algorithm to assign a weighted
45 | average value to each node that has one or more data points within a search
|
pygmt/src/nearneighbor.py:142:80: W505 Doc line too long (83 > 79 characters)
|
140 | >>> data = pygmt.datasets.load_sample_data(name="bathymetry")
141 | >>> # Create a new grid with 5 arc-minutes spacing in the designated region
142 | >>> # Set search_radius to only consider points within 10 arc-minutes of a node
| ^^^^ W505
143 | >>> output = pygmt.nearneighbor(
144 | ... data=data,
|
Found 9 errors. You're right that the long URLs from #2728 don't raise W505 errors anymore, but there are 9 others we'll need to fix. |
||
|
||
[tool.ruff.pycodestyle] | ||
max-doc-length = 79 | ||
|
||
[tool.flakeheaven.plugins] | ||
pycodestyle = ["+*", "-E501", "-W503"] | ||
pyflakes = ["+*"] | ||
[tool.ruff.per-file-ignores] | ||
"__init__.py" = ["F401"] # Ignore `F401` (unused-import) in all `__init__.py` files | ||
|
||
[tool.flakeheaven.exceptions."**/__init__.py"] | ||
pyflakes = ["-F401"] | ||
[tool.ruff.isort] | ||
known-third-party = ["pygmt"] | ||
|
||
[tool.pytest.ini_options] | ||
minversion = "6.0" | ||
addopts = "--verbose --durations=0 --durations-min=0.2 --doctest-modules --mpl --mpl-results-path=results" | ||
|
||
[tool.isort] | ||
profile = "black" | ||
skip_gitignore = true | ||
Comment on lines
-104
to
-106
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. Note that |
||
known_third_party = "pygmt" | ||
|
||
[tool.pylint.MASTER] | ||
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the | ||
# number of processors available to use. | ||
|
@@ -136,5 +139,5 @@ max-module-lines=2000 | |
disable=[ | ||
"duplicate-code", | ||
"import-error", | ||
"line-too-long", # Already checked by flakeheaven/pycodestyle | ||
"line-too-long", # Already checked by ruff's pycodestyle | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit ece0730, I had to move these
noqa: W505
(doc-too-long) comments (mostly added in #2728) to behind the triple quotes instead of inline, becauseruff
requires it to be like so. See astral-sh/ruff#3972 and https://docs.astral.sh/ruff/configuration/#error-suppression.