diff --git a/.github/workflows/style_checks.yaml b/.github/workflows/style_checks.yaml index 949329b039d..7a78305b501 100644 --- a/.github/workflows/style_checks.yaml +++ b/.github/workflows/style_checks.yaml @@ -39,7 +39,7 @@ jobs: - name: List installed packages run: python -m pip list - - name: Formatting check (ruff + prek) + - name: Formatting check (Ruff + prek) run: | make check prek run --all-files diff --git a/Makefile b/Makefile index df373dd8ef0..5e3ecd24929 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ help: @echo " fulltest run the test suite (including all doctests)" @echo " doctest run the doctests only" @echo " test_no_images run the test suite (including all doctests) but skip image comparisons" - @echo " format run ruff to automatically format the code" - @echo " check run ruff to check code style and quality" + @echo " format run Ruff to automatically format the code" + @echo " check run Ruff to check code style and quality" @echo " codespell run codespell to check common misspellings" @echo " typecheck run mypy for static type check" @echo " clean clean up build and generated files" diff --git a/doc/changes.md b/doc/changes.md index 68239a973a6..9b93396a748 100644 --- a/doc/changes.md +++ b/doc/changes.md @@ -199,7 +199,7 @@ * Set registration and gtype properly as enums on gmt accessor init ([#3942](https://github.com/GenericMappingTools/pygmt/pull/3942)) * Set license and license-files key in project metadata to follow PEP639 ([#3699](https://github.com/GenericMappingTools/pygmt/pull/3699)) * CI: Test NumPy 2.3 in the GMT Tests workflow ([#3968](https://github.com/GenericMappingTools/pygmt/pull/3968)) -* Bump to ruff>=0.12.0 and fix violations ([#3980](https://github.com/GenericMappingTools/pygmt/pull/3980)) +* Bump to Ruff>=0.12.0 and fix violations ([#3980](https://github.com/GenericMappingTools/pygmt/pull/3980)) **Full Changelog**: @@ -251,7 +251,7 @@ * Use the 'release-branch-semver' version scheme for setuptools_scm ([#3828](https://github.com/GenericMappingTools/pygmt/pull/3828)) * Rename _GMT_DATASET.to_dataframe to .to_pandas and _GMT_GRID.to_dataarray/_GMT_IMAGE.to_dataarray to .to_xarray ([#3798](https://github.com/GenericMappingTools/pygmt/pull/3798)) -* Bump to ruff 0.9.0, apply ruff 2025 style, and ignore A005 (stdlib-module-shadowing) violations ([#3763](https://github.com/GenericMappingTools/pygmt/pull/3763)) +* Bump to Ruff 0.9.0, apply Ruff 2025 style, and ignore A005 (stdlib-module-shadowing) violations ([#3763](https://github.com/GenericMappingTools/pygmt/pull/3763)) * Use well-known labels in project URLs following PEP753 ([#3743](https://github.com/GenericMappingTools/pygmt/pull/3743)) * clib.conversion: Remove the unused array_to_datetime function ([#3507](https://github.com/GenericMappingTools/pygmt/pull/3507)) * CI: Test on Linux arm64 runners ([#3778](https://github.com/GenericMappingTools/pygmt/pull/3778)) @@ -396,10 +396,10 @@ * Use TODO comments to track deprecations and workarounds ([#3722](https://github.com/GenericMappingTools/pygmt/pull/3722)) * Move Figure.psconvert into a separate file ([#3553](https://github.com/GenericMappingTools/pygmt/pull/3553)) * Improve the data type checking for 2-D arrays passed to the GMT C API ([#3563](https://github.com/GenericMappingTools/pygmt/pull/3563)) -* Enable ruff's TD (flake8-todos), COM (flake8-commas), TRY (tryceratops), and EM (flake8-errmsg) rules ([#3723](https://github.com/GenericMappingTools/pygmt/pull/3723), [#3531](https://github.com/GenericMappingTools/pygmt/pull/3531), [#3665](https://github.com/GenericMappingTools/pygmt/pull/3665), [#3661](https://github.com/GenericMappingTools/pygmt/pull/3661)) +* Enable Ruff's TD (flake8-todos), COM (flake8-commas), TRY (tryceratops), and EM (flake8-errmsg) rules ([#3723](https://github.com/GenericMappingTools/pygmt/pull/3723), [#3531](https://github.com/GenericMappingTools/pygmt/pull/3531), [#3665](https://github.com/GenericMappingTools/pygmt/pull/3665), [#3661](https://github.com/GenericMappingTools/pygmt/pull/3661)) * CI: Install pyarrow-core instead of pyarrow from conda-forge ([#3698](https://github.com/GenericMappingTools/pygmt/pull/3698)) * CI: Ensure no hyphens in Python file and directory names in the "Style Checks" workflow ([#3703](https://github.com/GenericMappingTools/pygmt/pull/3703)) -* Bump to ruff>=0.8.0 and rename rule TCH to TC ([#3662](https://github.com/GenericMappingTools/pygmt/pull/3662)) +* Bump to Ruff>=0.8.0 and rename rule TCH to TC ([#3662](https://github.com/GenericMappingTools/pygmt/pull/3662)) * Bump to Ghostscript 10.04.0 ([#3443](https://github.com/GenericMappingTools/pygmt/pull/3443)) * Add enums GridFormat for GMT grid format ID ([#3449](https://github.com/GenericMappingTools/pygmt/pull/3449)) @@ -479,8 +479,8 @@ * Run pytest with `--color=yes` to force GitHub Actions logs to have color ([#3330](https://github.com/GenericMappingTools/pygmt/pull/3330)) * Patch the callback print function to suppress the UnicodeDecodeError ([#3367](https://github.com/GenericMappingTools/pygmt/pull/3367)) * Move Will from Active Maintainers to Distinguished Contributors ([#3388](https://github.com/GenericMappingTools/pygmt/pull/3388)) -* Enable ruff's unspecified-encoding (PLW1514) rule and fix violations ([#3319](https://github.com/GenericMappingTools/pygmt/pull/3319)) -* Enable ruff's literal-membership (PLR6201) rule and fix violations ([#3317](https://github.com/GenericMappingTools/pygmt/pull/3317)) +* Enable Ruff's unspecified-encoding (PLW1514) rule and fix violations ([#3319](https://github.com/GenericMappingTools/pygmt/pull/3319)) +* Enable Ruff's literal-membership (PLR6201) rule and fix violations ([#3317](https://github.com/GenericMappingTools/pygmt/pull/3317)) * Determine the minimum required versions of dependencies from package metadata for docs ([#3380](https://github.com/GenericMappingTools/pygmt/pull/3380)) * CI: Use OIDC token for codecov uploading ([#3163](https://github.com/GenericMappingTools/pygmt/pull/3163)) * CI: Test NumPy 2.1 in the GMT Tests workflow ([#3401](https://github.com/GenericMappingTools/pygmt/pull/3401)) @@ -575,9 +575,9 @@ * Remote Datasets: Adjust attributes - remove "title", use default of "name" and "long_name", introduce "description" ([#3048](https://github.com/GenericMappingTools/pygmt/pull/3048)) * Adopt SPEC 0 policy and drop NEP 29 policy ([#3037](https://github.com/GenericMappingTools/pygmt/pull/3037)) * Document the support policy for minimum required GMT versions ([#3070](https://github.com/GenericMappingTools/pygmt/pull/3070)) -* Bump to ghostscript 10.03.0 ([#3112](https://github.com/GenericMappingTools/pygmt/pull/3112)) -* Bump to ruff 0.3.0 ([#3081](https://github.com/GenericMappingTools/pygmt/pull/3081)) -* Enable ruff's PTH (flake8-use-pathlib) rules and fix violations ([#3129](https://github.com/GenericMappingTools/pygmt/pull/3129)) +* Bump to Ghostscript 10.03.0 ([#3112](https://github.com/GenericMappingTools/pygmt/pull/3112)) +* Bump to Ruff 0.3.0 ([#3081](https://github.com/GenericMappingTools/pygmt/pull/3081)) +* Enable Ruff's PTH (flake8-use-pathlib) rules and fix violations ([#3129](https://github.com/GenericMappingTools/pygmt/pull/3129)) * Change the dev dependency "matplotlib" to "matplotlib-base" to reduce environment size ([#3158](https://github.com/GenericMappingTools/pygmt/pull/3158)) * Migrate from os.path to pathlib ([#3119](https://github.com/GenericMappingTools/pygmt/pull/3119)) * CI: Use "gh release" to upload assets to release ([#3187](https://github.com/GenericMappingTools/pygmt/pull/3187)) @@ -668,7 +668,7 @@ * Setup Continuous Benchmarking workflow with pytest-codspeed ([#2908](https://github.com/GenericMappingTools/pygmt/pull/2908)) * Update output shape and mean values from some x2sys_cross tests ([#2986](https://github.com/GenericMappingTools/pygmt/pull/2986)) * Bump the GMT version in CI to 6.5.0 ([#2962](https://github.com/GenericMappingTools/pygmt/pull/2962)) -* Bump ghostscript to 10.02.1 ([#2694](https://github.com/GenericMappingTools/pygmt/pull/2694)) +* Bump Ghostscript to 10.02.1 ([#2694](https://github.com/GenericMappingTools/pygmt/pull/2694)) * Add support for Python 3.12 ([#2711](https://github.com/GenericMappingTools/pygmt/pull/2711)) * NEP29: Test PyGMT on NumPy 1.26 ([#2692](https://github.com/GenericMappingTools/pygmt/pull/2692)) * CI: Trigger the cache_data workflow in PRs if cache files are added/deleted/updated ([#2939](https://github.com/GenericMappingTools/pygmt/pull/2939)) @@ -694,7 +694,7 @@ * Release Drafter: Automatically replace GitHub handles with names and links ([#2777](https://github.com/GenericMappingTools/pygmt/pull/2777)) * Exclude CODE_OF_CONDUCT.md, AUTHORSHIP.md and pygmt/tests directory from distributions ([#2957](https://github.com/GenericMappingTools/pygmt/pull/2957)) * Add Zenodo's GMT community to the maintainer's onboarding list ([#2761](https://github.com/GenericMappingTools/pygmt/pull/2761)) -* Use ruff to lint and format codes, and remove flakeheaven/isort/black/blackdoc ([#2741](https://github.com/GenericMappingTools/pygmt/issues/2741)) +* Use Ruff to lint and format codes, and remove flakeheaven/isort/black/blackdoc ([#2741](https://github.com/GenericMappingTools/pygmt/issues/2741)) * Use codespell to check common misspellings ([#2673](https://github.com/GenericMappingTools/pygmt/pull/2673)) * Use "# %%" as code block separators in examples ([#2662](https://github.com/GenericMappingTools/pygmt/pull/2662)) diff --git a/doc/contributing.md b/doc/contributing.md index a1b540d70d4..9f316456d42 100644 --- a/doc/contributing.md +++ b/doc/contributing.md @@ -407,7 +407,7 @@ the `pygmt/src/` and `pygmt/datasets/` folders. **All docstrings** should follow All functions/classes/methods should have docstrings with a full description of all arguments and return values. -While the maximum line length for code is automatically set by ruff, docstrings +While the maximum line length for code is automatically set by Ruff, docstrings must be formatted manually. To play nicely with Jupyter and IPython, **keep docstrings limited to 88 characters** per line. @@ -475,7 +475,7 @@ section. ### Code Style -We use the [ruff](https://docs.astral.sh/ruff) tool to format the code, so we +We use the [Ruff](https://docs.astral.sh/ruff) tool to format the code, so we don't have to think about it. It loosely follows the [PEP8](https://pep8.org) guide but with a few differences. Regardless, you won't have to worry about formatting the code yourself. Before committing, run it to automatically format your code: @@ -504,14 +504,14 @@ editors or IDEs. We consistently use `# %%` as code block separators (please refer to [issue #2660](https://github.com/GenericMappingTools/pygmt/issues/2660) for the discussions) and require at least one separator in all example files. -We also use [ruff](https://docs.astral.sh/ruff) to check the quality of the code +We also use [Ruff](https://docs.astral.sh/ruff) to check the quality of the code and quickly catch common errors. The [`Makefile`](https://github.com/GenericMappingTools/pygmt/blob/main/Makefile) contains rules for running the linter checks: ```bash -make check # Runs ruff in check mode +make check # Runs Ruff in check mode ``` ### Wrapping a GMT Module diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 8ae539afcb1..55fd9d4a81f 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -191,7 +191,7 @@ def test_earth_relief_holes(): npt.assert_allclose(grid.max(), 1601) npt.assert_allclose(grid.min(), -4929.5) # Test for the NaN values in the remote file - assert grid[2, 21].isnull() # noqa: PD003 # ruff's bug + assert grid[2, 21].isnull() # noqa: PD003 # Ruff's bug def test_maunaloa_co2(): diff --git a/pyproject.toml b/pyproject.toml index 232e16954d3..332f4c00a10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,7 +119,7 @@ select = [ "PTH", # flake8-use-pathlib "RET", # flake8-return "RSE", # flake8-raise - "RUF", # ruff-specific + "RUF", # Ruff-specific "S", # flake8-bandit "SIM", # flake8-simplify "T20", # flake8-print