fury-gl / fury

FURY - Free Unified Rendering in pYthon.
https://fury.gl
Other
226 stars 165 forks source link

STYLE: Transition to `ruff` to enforce import statement sorting #879

Closed jhlegarreta closed 2 months ago

jhlegarreta commented 2 months ago

Prefer using ruff instead of isort to enforce import statement sorting.

ruff's import sorting rules are near-equivalent to isort's when using isort's profile="black": https://docs.astral.sh/ruff/faq/#how-does-ruffs-import-sorting-compare-to-isort

Change the tool.isort section in pyproject so that the correspoding tasks fall under the responsibility of flake8.

Adapt accordingly the pre-commit hook config file to apply the import sorting to local files prior to commits.

Add a GHA workflow to apply the pre-commit hooks in order to ensure that files modified across commits/in PRs comply with the expected formatting.

jhlegarreta commented 2 months ago

@skoudoro Slight differences between isort and ruff. I've checked that the changes are also consistent with what ruff did for DIPY, e.g.: https://github.com/dipy/dipy/pull/3184/files#diff-0b50e0854fbf05412be4bc9cbd9852d4627500eb598d0fc05850998fe93e73e6R6

Would have expected all from y import z come after all import x, but looks like it is not the case always.

Anyways, green light to fix the issues and continue making steps towards adopting ruff?

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 84.47%. Comparing base (a4d6792) to head (4b79dbc).

:exclamation: Current head 4b79dbc differs from pull request most recent head b6f7bac. Consider uploading reports for the commit b6f7bac to get more accurate results

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/fury-gl/fury/pull/879/graphs/tree.svg?width=650&height=150&src=pr&token=wrshJ6dyDs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fury-gl)](https://app.codecov.io/gh/fury-gl/fury/pull/879?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fury-gl) ```diff @@ Coverage Diff @@ ## master #879 +/- ## ======================================= Coverage 84.47% 84.47% ======================================= Files 44 44 Lines 10529 10529 Branches 1418 1418 ======================================= Hits 8894 8894 Misses 1264 1264 Partials 371 371 ```
skoudoro commented 2 months ago

Hi @jhlegarreta,

All good.

However, the code format is failing. do you want to fix it here or in a new PR ?

jhlegarreta commented 2 months ago

However, the code format is failing. do you want to fix it here or in a new PR ?

Doing it here.