Skip to content

docs: Adding section on Ruff in code style tools page #592

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

Merged
merged 8 commits into from
May 14, 2025
Merged

Conversation

ecoussoux-ansys
Copy link
Contributor

@ecoussoux-ansys ecoussoux-ansys commented Apr 28, 2025

This PR implements the changes discussed in #589, i.e. replacing the sections in the code style tools documentation presenting Black, isort and Flake8 for code formatting and linting by a brief overview on how to perform these tasks with Ruff. Other parts of the documentation are also updated where necessary to take this change into account.

Ruff is introduced as a faster alternative to the previously used tools, combining in one common interface the features of interest for formatting and linting. A few key facts about Ruff are cited, a minimum Ruff setup for PyAnsys projects is provided and a recommended approach to add rules incrementally when migrating a project towards using Ruff is suggested.

As mentioned in #589, it should be noted 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 is left unchanged, despite the remaining dependence on Black.

Close #589

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 28, 2025
Copy link
Contributor

@SMoraisAnsys SMoraisAnsys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I left minor comments

@ecoussoux-ansys ecoussoux-ansys marked this pull request as ready for review May 7, 2025 12:55
Copy link
Contributor

@SMoraisAnsys SMoraisAnsys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ecoussoux-ansys, I left a minor comment

@SMoraisAnsys SMoraisAnsys merged commit 3d31419 into main May 14, 2025
8 checks passed
@SMoraisAnsys SMoraisAnsys deleted the docs/ruff branch May 14, 2025 07:45
github-actions bot pushed a commit that referenced this pull request May 14, 2025
* docs: Adding section on Ruff in code style tools page

* docs: Removing sections on Black, isort and Flake8 in code style tools page

* docs: Updating based on review comments

* docs: Harmonising documentation with changes made to code style tool page

* docs: Updating required-standard based on review comment

* Update doc/source/coding-style/required-standard.rst

---------

Co-authored-by: Sébastien Morais <[email protected]>
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 this pull request may close these issues.

Usage of Ruff for code formatting and linting
2 participants