Skip to content

Usage of Ruff for code formatting and linting #589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ecoussoux-ansys opened this issue Apr 28, 2025 · 0 comments · May be fixed by #592
Open

Usage of Ruff for code formatting and linting #589

ecoussoux-ansys opened this issue Apr 28, 2025 · 0 comments · May be fixed by #592
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@ecoussoux-ansys
Copy link

ecoussoux-ansys commented Apr 28, 2025

Description of the modifications

The section of the documentation about code style tools is discussing the use of Black and isort for code formatting and Flake8 for code linting (https://dev.docs.pyansys.com/coding-style/formatting-tools.html).
Moving forward, we might want to promote using Ruff ("an extremely fast Python linter and code formatter, written in Rust", see https://docs.astral.sh/ruff/) for both tasks and therefore remove the presentations of Blake, isort and Flake8.

In place of the brief descriptions of how to configure these three tools, a short overview of the main relevant features of Ruff could be provided - especially mentioning that it offers what the previous tools achieved - together with a possible approach to migrating a project towards using Ruff, by incrementally adding rules and fixing the triggered errors accordingly.

Other parts of the documentation will be updated to reflect this change where appropriate.
It should be noted, however, that blacken-docs, used for formatting Python code blocks in documentation files, cannot currently be replaced by Ruff, which does not support formatting/linting of embedded code (particularly in .rst or .md files, see astral-sh/ruff#8237). Similarly, blacken-docs does not support the Ruff formatter as an alternative for Black (see adamchainz/blacken-docs#352).
Therefore, the use of blacken-docs is still recommended and the section of the documentation presenting this tool will be left unchanged despite its dependence on Black.

Useful links and references

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant