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

Swap out Flake8 for ruff in linting #232

Merged
merged 4 commits into from
Jun 26, 2024
Merged

Swap out Flake8 for ruff in linting #232

merged 4 commits into from
Jun 26, 2024

Conversation

chouinar
Copy link
Contributor

@chouinar chouinar commented Jun 20, 2024

Ticket

Resolves #107

Changes

Change our linter from flake8 to ruff

Python package updates

Context for reviewers

ruff is a linter built in Rust that is both better performing and contains much more options than flake8 (including many of the Flake8 rules).

Ruff has a lot of potential rules we could configure, but to keep things simple, I ported over the same rules that we already had configured. If we want to try out any of the other rules, we can follow up with that. For context, enabling all rules causes ~1300 errors, although many of the common ones I see are not issues I think we would want to actually consider (complaining about using assert in test functions)

Ruff can also serve as a formatter of code, potentially replacing black + isort, but I'll explore using that later as the change is likely much bigger as it would cause a lot of little formatting differences

Testing

Was able to run ruff via make lint-ruff and only encountered a few small issues that I fixed.

We also switched to using this approach a few months ago in the simpler grants codebase and haven't run into any issues. HHS/simpler-grants-gov#1626

Copy link
Contributor

@KevinJBoyer KevinJBoyer left a comment

Choose a reason for hiding this comment

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

LGTM, though I didn't review openapi.generated.yml since I'm not sure that's intentionally part of this PR?

docs/app/formatting-and-linting.md Outdated Show resolved Hide resolved
docs/app/formatting-and-linting.md Show resolved Hide resolved
docs/app/formatting-and-linting.md Outdated Show resolved Hide resolved
@chouinar
Copy link
Contributor Author

LGTM, though I didn't review openapi.generated.yml since I'm not sure that's intentionally part of this PR?

I upgraded the versions of the packages, looks like something in one of the libraries that generate the spec got changed, although I'm not sure of what specifically. Those were about a year out of date, and I remember this changing a bit when I upgraded the simpler grants repo. Shouldn't be an issue?

@KevinJBoyer
Copy link
Contributor

@chouinar one other note (I just noticed it while looking at my own PR for moving the docker compose files) -- can you update the docs/app/README.md to remove setup.cfg from there?

@chouinar chouinar merged commit 39affbf into main Jun 26, 2024
4 checks passed
@chouinar chouinar deleted the chouinar/switch-to-ruff branch June 26, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider switching from flake8 to ruff
3 participants