Skip to content

Commit 26c484b

Browse files
committed
Updates
1 parent 72bf183 commit 26c484b

12 files changed

+38
-54
lines changed

pygmt/alias.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,6 @@ class Alias(NamedTuple):
3030
separator: str
3131

3232

33-
def sequence_to_str(seq, separator):
34-
"""
35-
Join a sequence (list, tuple) into a string with the specified separator.
36-
37-
Examples
38-
--------
39-
>>> sequence_to_str((1, 2, 3), "/")
40-
'1/2/3'
41-
>>> sequence_to_str((1, 2, 3), ",")
42-
'1,2,3'
43-
>>> sequence_to_str((1, 2, 3), " ")
44-
'1 2 3'
45-
"""
46-
return separator.join(str(item) for item in seq)
47-
48-
4933
def convert_aliases():
5034
"""
5135
Convert PyGMT parameters to GMT options.
@@ -83,12 +67,12 @@ def convert_aliases():
8367
params = p_locals.pop("kwargs", {}) | p_locals
8468

8569
# Define a dict to store GMT option flags and arguments
86-
kwdict = defaultdict(lambda: "") # use defaultdict to avoid KeyError
70+
kwdict = defaultdict(lambda: "") # default value is an empty string
8771
for alias in p_locals.get("_aliases"):
8872
value = params.get(alias.name)
8973
if is_nonstr_iter(value):
9074
if alias.separator != "":
91-
value = sequence_to_str(value, alias.separator)
75+
value = alias.separator.join(str(item) for item in value)
9276
else:
9377
value = ""
9478
elif value in (None, False): # None or False are skipped

pygmt/clib/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def create(self, name):
371371
self._error_log = []
372372

373373
@ctp.CFUNCTYPE(ctp.c_int, ctp.c_void_p, ctp.c_char_p)
374-
def print_func(file_pointer, message):
374+
def print_func(file_pointer, message): # noqa: ARG001
375375
"""
376376
Callback function that the GMT C API will use to print log and error
377377
messages.

pygmt/sphinx_gallery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PyGMTScraper:
1919
``conf.py`` as the ``"image_scrapers"`` argument.
2020
"""
2121

22-
def __call__(self, block, block_vars, gallery_conf):
22+
def __call__(self, block, block_vars, gallery_conf): # noqa: ARG002
2323
"""
2424
Called by sphinx-gallery to save the figures generated after running code.
2525
"""

pygmt/src/info.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ def info(
1717
per_column=None,
1818
spacing=None,
1919
nearest_multiple=None,
20-
verbose=None,
21-
aspatial=None,
22-
coltypes=None,
23-
incols=None,
24-
registration=None,
25-
**kwargs,
20+
verbose=None, # noqa: ARG001
21+
aspatial=None, # noqa: ARG001
22+
coltypes=None, # noqa: ARG001
23+
incols=None, # noqa: ARG001
24+
registration=None, # noqa: ARG001
25+
**kwargs, # noqa: ARG001
2626
):
2727
r"""
2828
Get information about data tables.

pygmt/src/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
@fmt_docstring
16-
def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwargs):
16+
def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwargs): # noqa: ARG001
1717
r"""
1818
Plot legends on maps.
1919

pygmt/src/text.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
@fmt_docstring
1919
@kwargs_to_strings(textfiles="sequence_space")
20-
def text_(
20+
def text_( # noqa: PLR0913
2121
self,
2222
textfiles=None,
2323
x=None,
@@ -27,8 +27,8 @@ def text_(
2727
angle=None,
2828
font=None,
2929
justify=None,
30-
projection=None,
31-
region=None,
30+
projection=None, # noqa: ARG001
31+
region=None, # noqa: ARG001
3232
transparency=None,
3333
**kwargs,
3434
):
@@ -213,7 +213,7 @@ def text_(
213213
# font or justify is str type
214214
for arg in (font, justify):
215215
if is_nonstr_iter(arg):
216-
extra_arrays.append(np.atleast_1d(arg).astype(str))
216+
extra_arrays.append(np.atleast_1d(arg).astype(str)) # noqa: PERF401
217217
# If an array of transparency is given, GMT will read it from
218218
# the last numerical column per data record.
219219
if is_nonstr_iter(transparency):

pygmt/src/timestamp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
def timestamp(
2222
self,
2323
text: str | None = None,
24-
label: str | None = None,
25-
justification: str = "BL",
24+
label: str | None = None, # noqa: ARG001
25+
justification: str = "BL", # noqa: ARG001
2626
offset: float | str | Sequence[float | str] = ("-54p", "-54p"),
2727
font: str = "Helvetica,black",
2828
timefmt: str = "%Y %b %d %H:%M:%S",

pygmt/src/xyz2grd.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@
1515

1616

1717
@fmt_docstring
18-
def xyz2grd(
18+
def xyz2grd( # noqa: PLR0913
1919
data=None,
2020
x=None,
2121
y=None,
2222
z=None,
2323
outgrid=None,
2424
spacing=None,
25-
duplicate=None,
26-
projection=None,
25+
duplicate=None, # noqa: ARG001
26+
projection=None, # noqa: ARG001
2727
region=None,
28-
verbose=None,
29-
convention=None,
30-
binary=None,
31-
nodata=None,
32-
find=None,
33-
coltypes=None,
34-
header=None,
35-
incols=None,
36-
registration=None,
37-
wrap=None,
38-
**kwargs,
28+
verbose=None, # noqa: ARG001
29+
convention=None, # noqa: ARG001
30+
binary=None, # noqa: ARG001
31+
nodata=None, # noqa: ARG001
32+
find=None, # noqa: ARG001
33+
coltypes=None, # noqa: ARG001
34+
header=None, # noqa: ARG001
35+
incols=None, # noqa: ARG001
36+
registration=None, # noqa: ARG001
37+
wrap=None, # noqa: ARG001
38+
**kwargs, # noqa: ARG001
3939
):
4040
r"""
4141
Create a grid file from table data.

pygmt/tests/test_clib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def mock(session, func, returns=None, mock_func=None):
3838
"""
3939
if mock_func is None:
4040

41-
def mock_api_function(*args):
41+
def mock_api_function(*args): # noqa: ARG001
4242
"""
4343
A mock GMT API function that always returns a given value.
4444
"""
@@ -525,7 +525,7 @@ def test_info_dict():
525525
assert lib.info
526526

527527
# Mock GMT_Get_Default to return always the same string
528-
def mock_defaults(api, name, value):
528+
def mock_defaults(api, name, value): # noqa: ARG001
529529
"""
530530
Put 'bla' in the value buffer.
531531
"""
@@ -554,7 +554,7 @@ def test_fails_for_wrong_version():
554554
"""
555555

556556
# Mock GMT_Get_Default to return an old version
557-
def mock_defaults(api, name, value):
557+
def mock_defaults(api, name, value): # noqa: ARG001
558558
"""
559559
Return an old version.
560560
"""

pygmt/tests/test_clib_loading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_load_libgmt_fails(monkeypatch):
8585
mpatch.setattr(
8686
subprocess,
8787
"check_output",
88-
lambda cmd, encoding: "libfakegmt.so",
88+
lambda cmd, encoding: "libfakegmt.so", # noqa: ARG005
8989
)
9090
with pytest.raises(GMTCLibNotFoundError):
9191
check_libgmt(load_libgmt())
@@ -220,7 +220,7 @@ class TestLibgmtCount:
220220
loaded_libgmt = load_libgmt() # Load the GMT library and reuse it when necessary
221221
counter = 0 # Global counter for how many times ctypes.CDLL is called
222222

223-
def _mock_ctypes_cdll_return(self, libname):
223+
def _mock_ctypes_cdll_return(self, libname): # noqa: ARG002
224224
"""
225225
Mock ctypes.CDLL to count how many times the function is called.
226226

pygmt/tests/test_figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def test_figure_savefig():
224224
"""
225225
kwargs_saved = []
226226

227-
def mock_psconvert(*args, **kwargs):
227+
def mock_psconvert(*args, **kwargs): # noqa: ARG001
228228
"""
229229
Just record the arguments.
230230
"""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ docstring-code-line-length = "dynamic"
8787
[tool.ruff.lint]
8888
select = [
8989
"A", # flake8-builtins
90-
#"ARG", # flake8-unused-arguments
90+
"ARG", # flake8-unused-arguments
9191
"B", # flake8-bugbear
9292
"BLE", # flake8-blind-except
9393
"C4", # flake8-comprehensions

0 commit comments

Comments
 (0)