Skip to content

CHORE: Setting up ruff#6157

Merged
SMoraisAnsys merged 16 commits into
mainfrom
chore/setup-ruff
May 22, 2025
Merged

CHORE: Setting up ruff#6157
SMoraisAnsys merged 16 commits into
mainfrom
chore/setup-ruff

Conversation

@ecoussoux-ansys
Copy link
Copy Markdown
Contributor

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

Description

This PR introduces the use of ruff for linting and formatting, replacing isort, black and flake8.
ruff is an extremely fast Python linter and code formatter, that integrates the functionalities of several tools behind a single, common interface (https://docs.astral.sh/ruff/)
Its implementation in pyaedt was suggested in issue #4775.
This PR can also be seen as contributing to the efforts described in issue #5504.

It should be noted that ruff does not replace the following tools, whose use in the project is therefore not affected by the changes made in this PR:

The changes in this PR are limited to the definition of a minimal configuration for ruff (in the pyproject.toml file) with only a few rules applied to the code base, together with the introduction of pre-commit hooks for linting and formatting with ruff. Python files fixed by ruff are updated. Configurations for isort, black and flake8 are removed and the associated pre-commit hooks are also dropped.
The currently ignored rules shall be gradually applied to the project in subsequent PRs. For this task, a useful command-line instruction can be used, which will return the number of errors flagged for each selected rule as well as the availability of automatic fixes : ruff check . --statistics

It is also worth mentioning that the list of rules selected until now for linting in the .flake8 file is not regarded as a reference for defining the ruff configuration implemented. Instead, this config is based on the recommendations from the pyansys-dev-guide, as introduced in ansys/pyansys-dev-guide#592.
Furthermore, the enforcement of ‘PTH’ type rules is not a priority as part of the introduction of ruff to the project, as an effort in this direction is currently underway as described in issue #5180.

Issue linked

Related to #4775 and #5504.

@ecoussoux-ansys ecoussoux-ansys self-assigned this May 15, 2025
@ansys-reviewer-bot
Copy link
Copy Markdown
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

@github-actions github-actions Bot added maintenance Package and maintenance related documentation Improvements or additions to documentation testing Anything related to testing labels May 15, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 90.27778% with 7 lines in your changes missing coverage. Please review.

Project coverage is 85.25%. Comparing base (459f92f) to head (77a85d2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6157      +/-   ##
==========================================
+ Coverage   84.41%   85.25%   +0.84%     
==========================================
  Files         170      170              
  Lines       64119    64119              
==========================================
+ Hits        54125    54666     +541     
+ Misses       9994     9453     -541     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ecoussoux-ansys ecoussoux-ansys marked this pull request as ready for review May 16, 2025 13:31
Copy link
Copy Markdown
Collaborator

@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 contribution @ecoussoux-ansys ! I left some minor changes that need to be taken care of before merging

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml
Comment thread pyproject.toml
Comment thread pyproject.toml
Comment thread pyproject.toml
@ecoussoux-ansys ecoussoux-ansys marked this pull request as draft May 19, 2025 08:42
@SMoraisAnsys SMoraisAnsys merged commit a37ccf5 into main May 22, 2025
34 checks passed
@SMoraisAnsys SMoraisAnsys deleted the chore/setup-ruff branch May 22, 2025 06:40
jsalant22 pushed a commit that referenced this pull request Jun 3, 2025
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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 maintenance Package and maintenance related testing Anything related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants