From 06ae8180fd0b398136e7cfd91932ec98407bff84 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 21 Dec 2023 13:33:15 +0800 Subject: [PATCH] Enable ruff's flake8-unused-arguments (ARG) rules (#2900) --- pygmt/clib/session.py | 2 +- pygmt/sphinx_gallery.py | 2 +- pygmt/tests/test_clib.py | 6 +++--- pygmt/tests/test_clib_loading.py | 4 +++- pygmt/tests/test_figure.py | 2 +- pygmt/tests/test_info.py | 2 +- pyproject.toml | 1 + 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index 2c0a9888c0b..cbf4ab03528 100644 --- a/pygmt/clib/session.py +++ b/pygmt/clib/session.py @@ -369,7 +369,7 @@ def create(self, name): self._error_log = [] @ctp.CFUNCTYPE(ctp.c_int, ctp.c_void_p, ctp.c_char_p) - def print_func(file_pointer, message): + def print_func(file_pointer, message): # noqa: ARG001 """ Callback function that the GMT C API will use to print log and error messages. diff --git a/pygmt/sphinx_gallery.py b/pygmt/sphinx_gallery.py index 4dc56d07286..a20b9689520 100644 --- a/pygmt/sphinx_gallery.py +++ b/pygmt/sphinx_gallery.py @@ -19,7 +19,7 @@ class PyGMTScraper: ``conf.py`` as the ``"image_scrapers"`` argument. """ - def __call__(self, block, block_vars, gallery_conf): + def __call__(self, block, block_vars, gallery_conf): # noqa: ARG002 """ Called by sphinx-gallery to save the figures generated after running code. diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index 29d6d6a5126..28d57ee6a4b 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -38,7 +38,7 @@ def mock(session, func, returns=None, mock_func=None): """ if mock_func is None: - def mock_api_function(*args): + def mock_api_function(*args): # noqa: ARG001 """ A mock GMT API function that always returns a given value. """ @@ -523,7 +523,7 @@ def test_info_dict(): assert lib.info # Mock GMT_Get_Default to return always the same string - def mock_defaults(api, name, value): + def mock_defaults(api, name, value): # noqa: ARG001 """ Put 'bla' in the value buffer. """ @@ -552,7 +552,7 @@ def test_fails_for_wrong_version(): """ # Mock GMT_Get_Default to return an old version - def mock_defaults(api, name, value): + def mock_defaults(api, name, value): # noqa: ARG001 """ Return an old version. """ diff --git a/pygmt/tests/test_clib_loading.py b/pygmt/tests/test_clib_loading.py index 31f9086a6cd..460f8e68a47 100644 --- a/pygmt/tests/test_clib_loading.py +++ b/pygmt/tests/test_clib_loading.py @@ -79,7 +79,9 @@ def test_load_libgmt_fails(monkeypatch): "darwin" if sys.platform == "linux" else "linux", ) mpatch.setattr( - subprocess, "check_output", lambda cmd, encoding: "libfakegmt.so" + subprocess, + "check_output", + lambda cmd, encoding: "libfakegmt.so", # noqa: ARG005 ) with pytest.raises(GMTCLibNotFoundError): check_libgmt(load_libgmt()) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 04b49c60ad7..e2385220d8e 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -225,7 +225,7 @@ def test_figure_savefig(): """ kwargs_saved = [] - def mock_psconvert(*args, **kwargs): + def mock_psconvert(*args, **kwargs): # noqa: ARG001 """ Just record the arguments. """ diff --git a/pygmt/tests/test_info.py b/pygmt/tests/test_info.py index 3ddbbe9bca0..b853789ad85 100644 --- a/pygmt/tests/test_info.py +++ b/pygmt/tests/test_info.py @@ -99,7 +99,7 @@ def test_info_dataframe(dtype): """ Make sure info works on pandas.DataFrame inputs. """ - table = pd.read_csv(POINTS_DATA, sep=" ", header=None) + table = pd.read_csv(POINTS_DATA, sep=" ", header=None, dtype=dtype) output = info(data=table) expected_output = ( ": N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n" diff --git a/pyproject.toml b/pyproject.toml index ebfdac94b1f..2380ed8cf9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,6 +100,7 @@ line-ending = "lf" # Use UNIX `\n` line endings for all files [tool.ruff.lint] select = [ "A", # flake8-builtins + "ARG", # flake8-unused-arguments "B", # flake8-bugbear "BLE", # flake8-blind-except "C4", # flake8-comprehensions