+
Skip to content

style: preparing actinia for Pylint 3.x with ruff #539

Open
@neteler

Description

@neteler

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载