Skip to content
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

MNT: Use ruff for formatting checks #2273

Merged
merged 1 commit into from
Nov 13, 2023
Merged

MNT: Use ruff for formatting checks #2273

merged 1 commit into from
Nov 13, 2023

Conversation

greglucas
Copy link
Contributor

Moves from flake8 and isort to ruff for the formatting checks. Also updates some of the sorted and formatted imports that were flagged by ruff. Ruff is significantly faster than flake8 / isort and we can also start adding additional checks later if we want. I looked at adding "D", but that is quite intimidating to update the docstrings right now with ~500-1k failures depending on which checks we want.

Copy link
Member

@rcomer rcomer left a comment

Choose a reason for hiding this comment

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

Makes sense to me. I tried it locally and in flies.

It looks like ruff will also autofix some white space problems. Does that mean that some of the smaller hooks are also redundant, or are they still needed for the non-python files?
https://docs.astral.sh/ruff/rules/#warning-w

Gridliner,
classic_formatter,
classic_locator,
)
Copy link
Member

Choose a reason for hiding this comment

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

I think I prefer the old style here, as I like the horizontal separation between modules and their objects. I can't see a setting for that though, and it isn't a deal-breaker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have a strong preference either way, so I was fine applying this. I think that ruff likely takes the black formatting approach and applies it liberally here even if we aren't using black. I also haven't found a setting to override this so I think we are stuck with it if we want to replace isort with ruff.

@greglucas
Copy link
Contributor Author

It looks like ruff will also autofix some white space problems. Does that mean that some of the smaller hooks are also redundant, or are they still needed for the non-python files?
https://docs.astral.sh/ruff/rules/#warning-w

I think we can probably start slowly moving over to ruff for these. But, I wasn't 100% sure so I didn't apply that here. But, we can definitely start adding more codes as we see fit and removing the redundant checks.

- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.292'
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bumped to v0.1.5 now.

setup.cfg Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
Moves from flake8 and isort to ruff for the formatting checks.
Also updates some of the sorted and formatted imports that
were flagged by ruff.
@rcomer
Copy link
Member

rcomer commented Nov 13, 2023

Let's do this!

@rcomer rcomer merged commit 1ec173c into SciTools:main Nov 13, 2023
22 checks passed
@QuLogic QuLogic added this to the 0.23 milestone Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants