Skip to content

Conversation

ecoussoux-ansys
Copy link
Contributor

@ecoussoux-ansys ecoussoux-ansys commented May 6, 2025

This PR implements the change discussed in #593, i.e. migrating the pyansys-dev-guide to Ruff.

The specific configs for Black, isort and flake8 are removed and the .pre-commit-config.yaml file is updated accordingly, while a ruff.toml file defining the rules used by Ruff for linting and formatting is introduced.
Python files fixed by Ruff are updated.

Since the project does not currently contain a pyproject.toml file, it was decided not to define one for the purpose of holding the Ruff configuration, but instead to specify it in a ruff.toml file placed at the root of the project. The introduction of a pyproject.toml file is considered to be beyond the scope of this PR, which is the motivation for this choice.
Should a pyproject.toml file be created in the future, the content of the ruff.toml can simply be added to it and this config file removed.

As indicated in #593, the use of blacken-docs in .pre-commit-config.yaml is maintained as this tool (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).
This tool is therefore retained (see here about the Ruff pre-commit hook astral-sh/ruff-pre-commit#55) for this project, despite the remaining dependence on Black.

Close #593

@github-actions github-actions bot added maintenance Package and maintenance related enhancement New features or code improvements labels May 6, 2025
@ecoussoux-ansys ecoussoux-ansys self-assigned this May 6, 2025
@github-actions github-actions bot added the documentation Improvements or additions to documentation label May 6, 2025
@ecoussoux-ansys ecoussoux-ansys marked this pull request as ready for review May 7, 2025 14:37
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 this PR @ecoussoux-ansys, I left some minor comments

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.

Here is a new batch of suggestion :)

@MaxJPRey
Copy link
Contributor

MaxJPRey commented May 14, 2025

Nice work. I am glad that our dev guide was updated according to our current guidance promoting ruff usage.

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

@SMoraisAnsys SMoraisAnsys changed the title feat: Setting up Ruff and updating the repo content accordingly chore: use ruff with ruff.toml file May 15, 2025
@SMoraisAnsys SMoraisAnsys merged commit 430e55a into main May 15, 2025
8 checks passed
@SMoraisAnsys SMoraisAnsys deleted the feat/setup-ruff branch May 15, 2025 07:16
github-actions bot pushed a commit that referenced this pull request May 15, 2025
* feat: Introducing Ruff config, removing .flake8, updating pre-commit-config

* feat: Adding ruff-format hook to pre-commit, updating fixed files

* feat: Adding linting rules to Ruff config, updating fixed file

* feat: Extending Ruff linting rules list, updating fixed files

* feat: Reverting change breaking doc build, updating ignored linting rules

* Apply suggestions from code review

Co-authored-by: Sébastien Morais <[email protected]>

* feat: Updating pyansys_logging and ruff config based on review comments

* Update doc/source/how-to/code/test_pyansys_logging.py

Co-authored-by: Sébastien Morais <[email protected]>

* feat: Removing ignored rules from ruff config and updating files accordingly

* Update doc/source/how-to/code/test_pyansys_logging.py

---------

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 enhancement New features or code improvements maintenance Package and maintenance related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up Ruff and remove previous tools for formatting and linting
3 participants