Skip to content

Commit 753a06e

Browse files
authored
Bump to ruff 0.9.0, apply ruff 2025 style, and ignore A005 (stdlib-module-shadowing) violations (#3763)
* Ignore A005 errors * Apply ruff styling changes in 2025 * Bump to ruff 0.9.0
1 parent 5041384 commit 753a06e

13 files changed

+19
-36
lines changed

doc/conf.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,10 @@
210210
repository = "GenericMappingTools/pygmt"
211211
repository_url = "https://github.com/GenericMappingTools/pygmt"
212212
if __commit__:
213-
commit_link = (
214-
f'<a href="{repository_url}/commit/{ __commit__ }">{ __commit__[:8] }</a>'
215-
)
213+
commit_link = f'<a href="{repository_url}/commit/{__commit__}">{__commit__[:8]}</a>'
216214
else:
217215
commit_link = (
218-
f'<a href="{repository_url}/releases/tag/{ __version__ }">{ __version__ }</a>'
216+
f'<a href="{repository_url}/releases/tag/{__version__}">{__version__}</a>'
219217
)
220218
html_context = {
221219
"menu_links": [

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies:
2727
# Dev dependencies (style checks)
2828
- codespell
2929
- pre-commit
30-
- ruff>=0.8.2
30+
- ruff>=0.9.0
3131
# Dev dependencies (unit testing)
3232
- matplotlib-base
3333
- pytest>=6.0

examples/tutorials/advanced/cartesian_histograms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@
348348
# of the bin width
349349
# Offset ("+o") the bars to align each bar with the left limit of the corresponding
350350
# bin
351-
barwidth=f"{binwidth/2}+o-{binwidth/4}",
351+
barwidth=f"{binwidth / 2}+o-{binwidth / 4}",
352352
label="data01",
353353
)
354354

@@ -359,7 +359,7 @@
359359
fill="orange",
360360
pen="1p,darkgray,solid",
361361
histtype=0,
362-
barwidth=f"{binwidth/2}+o{binwidth/4}",
362+
barwidth=f"{binwidth / 2}+o{binwidth / 4}",
363363
label="data02",
364364
)
365365

pygmt/_show_versions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pygmt.clib import Session, __gmt_version__
1717

1818
# Get semantic version through setuptools-scm
19-
__version__ = f'v{version("pygmt")}' # e.g. v0.1.2.dev3+g0ab3cd78
19+
__version__ = f"v{version('pygmt')}" # e.g. v0.1.2.dev3+g0ab3cd78
2020
__commit__ = __version__.split("+g")[-1] if "+g" in __version__ else "" # 0ab3cd78
2121

2222

pygmt/encodings.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# noqa: A005
12
"""
23
Character encodings supported by GMT.
34

pygmt/helpers/tempfile.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# noqa: A005
12
"""
23
Utilities for dealing with temporary file management.
34
"""

pygmt/helpers/utils.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,8 @@ def launch_external_viewer(fname: str, waiting: float = 0) -> None:
574574
}
575575

576576
match sys.platform:
577-
case name if (
578-
(name == "linux" or name.startswith("freebsd"))
579-
and (xdgopen := shutil.which("xdg-open"))
577+
case name if (name == "linux" or name.startswith("freebsd")) and (
578+
xdgopen := shutil.which("xdg-open")
580579
): # Linux/FreeBSD
581580
subprocess.run([xdgopen, fname], check=False, **run_args) # type:ignore[call-overload]
582581
case "darwin": # macOS

pygmt/io.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# noqa: A005
12
"""
23
PyGMT input/output (I/O) utilities.
34
"""

pygmt/src/grd2xyz.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ def grd2xyz(
145145

146146
if kwargs.get("o") is not None and output_type == "pandas":
147147
msg = (
148-
"If 'outcols' is specified, 'output_type' must be either 'numpy' "
149-
"or 'file'."
148+
"If 'outcols' is specified, 'output_type' must be either 'numpy' or 'file'."
150149
)
151150
raise GMTInvalidInput(msg)
152151
# Set the default column names for the pandas DataFrame header.

pygmt/src/select.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# noqa: A005
12
"""
23
select - Select data table subsets based on multiple spatial criteria.
34
"""

pygmt/tests/test_clib_virtualfile_from_stringio.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,9 @@ def test_virtualfile_from_stringio():
4343
Test the virtualfile_from_stringio method.
4444
"""
4545
data = io.StringIO(
46-
"# Comment\n"
47-
"H 24p Legend\n"
48-
"N 2\n"
49-
"S 0.1i c 0.15i p300/12 0.25p 0.3i My circle\n"
50-
)
51-
expected = (
52-
">\n" "H 24p Legend\n" "N 2\n" "S 0.1i c 0.15i p300/12 0.25p 0.3i My circle\n"
46+
"# Comment\nH 24p Legend\nN 2\nS 0.1i c 0.15i p300/12 0.25p 0.3i My circle\n"
5347
)
48+
expected = ">\nH 24p Legend\nN 2\nS 0.1i c 0.15i p300/12 0.25p 0.3i My circle\n"
5449
assert _stringio_to_dataset(data) == expected
5550

5651

@@ -66,13 +61,7 @@ def test_one_segment():
6661
"6 7 8 9 FGHIJK LMN OPQ\n"
6762
"RSTUVWXYZ\n"
6863
)
69-
expected = (
70-
"> Segment 1\n"
71-
"1 2 3 ABC\n"
72-
"4 5 DE\n"
73-
"6 7 8 9 FGHIJK LMN OPQ\n"
74-
"RSTUVWXYZ\n"
75-
)
64+
expected = "> Segment 1\n1 2 3 ABC\n4 5 DE\n6 7 8 9 FGHIJK LMN OPQ\nRSTUVWXYZ\n"
7665
assert _stringio_to_dataset(data) == expected
7766

7867

pygmt/tests/test_grdview.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def test_grdview_with_perspective_and_zaxis_frame(xrgrid, region):
161161
a Transverse Mercator (T) projection.
162162
"""
163163
fig = Figure()
164-
projection = f"T{(region[0]+region[1])/2}/{abs((region[2]+region[3])/2)}"
164+
projection = f"T{(region[0] + region[1]) / 2}/{abs((region[2] + region[3]) / 2)}"
165165
fig.grdview(
166166
grid=xrgrid,
167167
projection=projection,

pygmt/tests/test_info.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ def test_info():
2323
"""
2424
output = info(data=POINTS_DATA)
2525
expected_output = (
26-
f"{POINTS_DATA}: N = 20 "
27-
"<11.5309/61.7074> "
28-
"<-2.9289/7.8648> "
29-
"<0.1412/0.9338>\n"
26+
f"{POINTS_DATA}: N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n"
3027
)
3128
assert output == expected_output
3229

@@ -57,10 +54,7 @@ def test_info_path(table):
5754
"""
5855
output = info(data=table)
5956
expected_output = (
60-
f"{POINTS_DATA}: N = 20 "
61-
"<11.5309/61.7074> "
62-
"<-2.9289/7.8648> "
63-
"<0.1412/0.9338>\n"
57+
f"{POINTS_DATA}: N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n"
6458
)
6559
assert output == expected_output
6660

0 commit comments

Comments
 (0)