actinia-org / actinia-core

Actinia Core is an open source REST API for scalable, distributed, high performance processing of geographical data that uses mainly GRASS GIS for computational tasks (DOI: https://doi.org/10.5281/zenodo.5879231) | Tutorial: https://actinia-org.github.io/actinia-core/ | Docker: https://hub.docker.com/r/mundialis/actinia-core
https://actinia.mundialis.de/
GNU General Public License v3.0
78 stars 22 forks source link

style: preparing actinia for Pylint 3.x #539

Open neteler opened 2 weeks ago

neteler commented 2 weeks ago

Preparing the repo for Pylint 3.x

Motivation

In the GRASS GIS project the Pylint configuration is created from scratch. In preparation for that, the entire Python code is updated with ruff (https://docs.astral.sh/ruff/, an extremely fast Python linter) to comply with Pylint 3 rules.

Steps

Here the respective steps to which might be applied to the actinia-* repos as well.

(Source: various recent Python code cleanup PRs in the GRASS GIS project, see https://github.com/OSGeo/grass/pulls?q=is%3Apr+is%3Aclosed+style)

# style: Fix single-line-implicit-string-concatenation violations (ISC001)
ruff check --select "ISC001" --fix

# style: Fixes unnecessary-collection-call (C408) for empty collections
ruff check --select "C408" --unsafe-fixes --fix --config "lint.flake8-comprehensions.allow-dict-calls-with-keyword-arguments = true"

# style: Fixes unnecessary-collection-call (C408) for testsuite
ruff check --select "C408" --unsafe-fixes --output-format=concise --fix

# style: Fixes manual-from-import (PLR0402)
ruff check --output-format=concise --select PLR0402 --fix

# style: Fixes if-stmt-min-max (PLR1730)
ruff check --output-format=concise --select PLR1730 --preview --fix

# style: Fixes sys-exit-alias (PLR1722)
ruff check --select "PLR1722" --unsafe-fixes --output-format=concise --fix

# style: Fixes literal-membership (PLR6201)
ruff check --output-format=concise --select PLR6201 --preview --unsafe-fixes --fix

# style: Fixes useless-return (PLR1711)
ruff check --output-format=concise --select PLR1711 --fix

# style: Fixes useless-exception-statement (PLW0133)
ruff check --output-format=concise --select PLW0133 --unsafe-fixes --fix

# style: Sort and group imports
ruff check --output-format=concise --select I --fix
isort --profile=black .
black .

# style: Fixes some unnecessary-lambda (PLW0108)
ruff check --output-format=concise --select PLW0108 --preview --fix --unsafe-fixes

Some fine tuning might be needed but most will be straight-forward.