Skip to content
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

Bump to ruff 0.9.0, apply ruff 2025 style, and ignore A005 (stdlib-module-shadowing) violations #3763

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,10 @@
repository = "GenericMappingTools/pygmt"
repository_url = "https://github.com/GenericMappingTools/pygmt"
if __commit__:
commit_link = (
f'<a href="{repository_url}/commit/{ __commit__ }">{ __commit__[:8] }</a>'
)
commit_link = f'<a href="{repository_url}/commit/{__commit__}">{__commit__[:8]}</a>'
else:
commit_link = (
f'<a href="{repository_url}/releases/tag/{ __version__ }">{ __version__ }</a>'
f'<a href="{repository_url}/releases/tag/{__version__}">{__version__}</a>'
)
html_context = {
"menu_links": [
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies:
# Dev dependencies (style checks)
- codespell
- pre-commit
- ruff>=0.8.2
- ruff>=0.9.0
# Dev dependencies (unit testing)
- matplotlib-base
- pytest>=6.0
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/advanced/cartesian_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
# of the bin width
# Offset ("+o") the bars to align each bar with the left limit of the corresponding
# bin
barwidth=f"{binwidth/2}+o-{binwidth/4}",
barwidth=f"{binwidth / 2}+o-{binwidth / 4}",
label="data01",
)

Expand All @@ -359,7 +359,7 @@
fill="orange",
pen="1p,darkgray,solid",
histtype=0,
barwidth=f"{binwidth/2}+o{binwidth/4}",
barwidth=f"{binwidth / 2}+o{binwidth / 4}",
label="data02",
)

Expand Down
2 changes: 1 addition & 1 deletion pygmt/_show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pygmt.clib import Session, __gmt_version__

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


Expand Down
1 change: 1 addition & 0 deletions pygmt/encodings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa: A005
"""
Character encodings supported by GMT.

Expand Down
1 change: 1 addition & 0 deletions pygmt/helpers/tempfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa: A005
"""
Utilities for dealing with temporary file management.
"""
Expand Down
5 changes: 2 additions & 3 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,8 @@ def launch_external_viewer(fname: str, waiting: float = 0) -> None:
}

match sys.platform:
case name if (
(name == "linux" or name.startswith("freebsd"))
and (xdgopen := shutil.which("xdg-open"))
case name if (name == "linux" or name.startswith("freebsd")) and (
xdgopen := shutil.which("xdg-open")
): # Linux/FreeBSD
subprocess.run([xdgopen, fname], check=False, **run_args) # type:ignore[call-overload]
case "darwin": # macOS
Expand Down
1 change: 1 addition & 0 deletions pygmt/io.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa: A005
"""
PyGMT input/output (I/O) utilities.
"""
Expand Down
3 changes: 1 addition & 2 deletions pygmt/src/grd2xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def grd2xyz(

if kwargs.get("o") is not None and output_type == "pandas":
msg = (
"If 'outcols' is specified, 'output_type' must be either 'numpy' "
"or 'file'."
"If 'outcols' is specified, 'output_type' must be either 'numpy' or 'file'."
)
raise GMTInvalidInput(msg)
# Set the default column names for the pandas DataFrame header.
Expand Down
1 change: 1 addition & 0 deletions pygmt/src/select.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa: A005
"""
select - Select data table subsets based on multiple spatial criteria.
"""
Expand Down
17 changes: 3 additions & 14 deletions pygmt/tests/test_clib_virtualfile_from_stringio.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,9 @@ def test_virtualfile_from_stringio():
Test the virtualfile_from_stringio method.
"""
data = io.StringIO(
"# Comment\n"
"H 24p Legend\n"
"N 2\n"
"S 0.1i c 0.15i p300/12 0.25p 0.3i My circle\n"
)
expected = (
">\n" "H 24p Legend\n" "N 2\n" "S 0.1i c 0.15i p300/12 0.25p 0.3i My circle\n"
"# Comment\nH 24p Legend\nN 2\nS 0.1i c 0.15i p300/12 0.25p 0.3i My circle\n"
)
expected = ">\nH 24p Legend\nN 2\nS 0.1i c 0.15i p300/12 0.25p 0.3i My circle\n"
assert _stringio_to_dataset(data) == expected


Expand All @@ -66,13 +61,7 @@ def test_one_segment():
"6 7 8 9 FGHIJK LMN OPQ\n"
"RSTUVWXYZ\n"
)
expected = (
"> Segment 1\n"
"1 2 3 ABC\n"
"4 5 DE\n"
"6 7 8 9 FGHIJK LMN OPQ\n"
"RSTUVWXYZ\n"
)
expected = "> Segment 1\n1 2 3 ABC\n4 5 DE\n6 7 8 9 FGHIJK LMN OPQ\nRSTUVWXYZ\n"
assert _stringio_to_dataset(data) == expected


Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_grdview_with_perspective_and_zaxis_frame(xrgrid, region):
a Transverse Mercator (T) projection.
"""
fig = Figure()
projection = f"T{(region[0]+region[1])/2}/{abs((region[2]+region[3])/2)}"
projection = f"T{(region[0] + region[1]) / 2}/{abs((region[2] + region[3]) / 2)}"
fig.grdview(
grid=xrgrid,
projection=projection,
Expand Down
10 changes: 2 additions & 8 deletions pygmt/tests/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ def test_info():
"""
output = info(data=POINTS_DATA)
expected_output = (
f"{POINTS_DATA}: N = 20 "
"<11.5309/61.7074> "
"<-2.9289/7.8648> "
"<0.1412/0.9338>\n"
f"{POINTS_DATA}: N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n"
)
assert output == expected_output

Expand Down Expand Up @@ -57,10 +54,7 @@ def test_info_path(table):
"""
output = info(data=table)
expected_output = (
f"{POINTS_DATA}: N = 20 "
"<11.5309/61.7074> "
"<-2.9289/7.8648> "
"<0.1412/0.9338>\n"
f"{POINTS_DATA}: N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n"
)
assert output == expected_output

Expand Down
Loading