DiddiLeija / diddi-and-the-bugs

Diddi and the Bugs, my GameOff 2021 game.
https://diddileija.itch.io/diddi-and-the-bugs
MIT License
7 stars 3 forks source link

Feat: Migrate to ruff? #136

Closed DiddiLeija closed 9 months ago

DiddiLeija commented 1 year ago

Is your feature request related to a problem? Please describe.

Currently, our codebase is linted by a bunch of known tools: black, isort, and flake8. And they're fine, but sometimes a little slow.

Describe the solution you'd like

Ruff is a somewhat new linting/formatting tool. I haven't tried it yet on a GitHub codebase, but I've seen how other (way bigger) projects are using it, like Nox, and how their CI runtimes are way faster since then.

It turns out that Ruff covers what our current tools do (and even more), and does it much faster and clearly. I would like to adopt Ruff and eventually drop our current tools (which will be covered by Ruff itself).

Procedure

First, we have to add ruff [^1] to the test-requirements.txt requirements file.

Then, in our noxfile:

https://github.com/DiddiLeija/diddi-and-the-bugs/blob/234a2144b9c7b7640204796867099dcf1921b923/noxfile.py#L16-L30

We'll replace all the session.run(...) lines with these few instructions:

And that should be enough. There's a chance that some Ruff checks will fail, if so you could run ruff check --fix . locally and then upload the fixed files ;)

Describe alternatives you've considered

Keep as-is, which is also a decent choice.

Additional context

I've marked this as a good first issue since I would like a newcomer to take this issue :) Above I've left a few instructions in case somebody wants to push this forward (see the Procedure section)!

[^1]: At the requirements file, I would prefer to pin the latest version of Ruff (which will be safely verified and updated by @dependabot everyday), instead of mindlessly installing the latest one on each run. For example, the latest Ruff version (as of October 3th, 2023) is 0.0.292, so we should add ruff==0.0.292 to the requirements file, instead of a plain ruff :wink:

DiddiLeija commented 1 year ago

Turns out that having a single formatting tool would help us a lot -- in #142, we had trouble because Black and Flake8 disagreed on a few lines.