CHORE: Enforce ruff pyflakes F rules#6239
Merged
Merged
Conversation
Contributor
|
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (80.00%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #6239 +/- ##
=======================================
Coverage 85.29% 85.29%
=======================================
Files 173 173
Lines 65310 65273 -37
=======================================
- Hits 55705 55677 -28
+ Misses 9605 9596 -9 🚀 New features to boost your workflow:
|
Collaborator
SMoraisAnsys
left a comment
There was a problem hiding this comment.
Thanks for the changes @ecoussoux-ansys !!!
I left some comments. I'm wondering if some of the changes are due to ruff or if they are changes performed in the main branch and somehow reflected in this PR. Can you have a look and address them ?
Samuelopez-ansys
previously approved these changes
Jun 23, 2025
SMoraisAnsys
previously approved these changes
Jun 23, 2025
5e9a2f0
Samuelopez-ansys
approved these changes
Jun 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR is a follow-up to #6157, which introduced a minimal configuration for
ruffto pyaedt and to #6203, which applied the "E" rules (related to pycodestyle) on the entire codebase.Here, the "F" rules (related to Pyflakes, see https://docs.astral.sh/ruff/rules/#pyflakes-f) are enforced, allowing their removal from the list of ignored linting rules for
ruff.This effort is part of the migration of pyaedt towards using
rufffor code formatting and linting, as requested in issue #4775.This PR is also contributing to the efforts described in issue #5504.
"F" rules were incrementally applied (one rule per commit) using the same approach as in #6203.
The strategy followed for enforcing this set of rules has been to avoid as much as possible the deactivation of specific checks on a per-file basis and the creation of special cases. This has occasionally involved introducing some debatable changes, which reviewers might want to pay particular attention to: These are listed below, together with other non-trivial modifications suggested in this PR:
unused-import) in__init__.pyfiles was to follow one of the methods described in https://docs.astral.sh/ruff/rules/unused-import/, which consists in explicitly declaring the imported symbols as part of the modules' interfaces using__all__. Some instances of in-filenoqa: F401were also removed where possible,src/ansys/aedt/core/__init__.pywas applied, so that variables and classes are directly imported from the modules in which these are defined,undefined-local-with-import-star) only impacted files in thesrc/pyaedt/folder. Therefore, it was decided to ignore this rule for all files from this folder in order not to invest time in tedious refactoring of this deprecated part of the codebase,undefined-name) is ignored in filedoc/source/Resources/pyaedt_installer_from_aedt.pyfor lack of a better alternative for managing variables specific to IronPython with respect to this rule,test_plot_insertion_lossesintest_touchstone_data.pywas modified. Currently the variableresreturned line 32 is equal to[]:res is not []returnsTruebut the syntaxres != []recommended byruffwill returnFalse. Therefore, the asserted equality is rewritten tores == [], in line with the result actually obtained from this test, despite it seeming to contradict the previous implementation for this check,ruffpre-commit hook is updated in.pre-commit-config.yaml.Issue linked
Related to #4775 and #5504.