navapbc / template-application-flask

Apache License 2.0
7 stars 3 forks source link

Swap out Flake8 for ruff in linting #232

Closed chouinar closed 2 months ago

chouinar commented 2 months ago

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. https://github.com/HHS/simpler-grants-gov/pull/1626

chouinar commented 2 months ago

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 commented 2 months ago

@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?