zetonteam / zeton_django

Hacktoberfest
Apache License 2.0
10 stars 2 forks source link

feat: introduce unform code formatting with ruff 💪💪💪 #67

Closed szmktk closed 3 months ago

szmktk commented 3 months ago

Introducing ruff. This PR is quite big but the contents do not modify the code functionally at all, just formats it in unified manner.

Ruff is invoked as a pre-commit hook. pre-commit install instructions will be are now added to README.md soon :slightly_smiling_face: but for now you need to run this command once in order to use ruff with pre-commit:

# install pre-commit on your machine, I recommend pipx (but pipx needs to be installed beforehad as well :sweat_smile:)
$ pipx install pre-commit
$ pre-commit run -a
MateuszBelczowski commented 3 months ago

@szmktk What do you think about configuring git to ignore this reformatting commit when running git blame? Here's example from Black's docs (solution is tool agnostic, so it doesn't matter that we're not using black) https://black.readthedocs.io/en/stable/guides/introducing_black_to_your_project.html#avoiding-ruining-git-blame

szmktk commented 3 months ago

@MateuszBelczowski Sure thing! I didn't even know that such a setting even exists! Thanks for sharing that, I'll re-do the commit and push :ok_hand:

szmktk commented 3 months ago

@MateuszBelczowski This --ignore-rev option seems to only have effect when configured on developers' local machine.

One needs to pass commit sha1 either directly on command line or in a specific file in order for this to work.

I cannot modify your local git config, all I can do is include .git-blame-ignore-revs file with the commit id that is the subject of this PR. The question is how badly you need this 😁 ?

MateuszBelczowski commented 3 months ago

@MateuszBelczowski This --ignore-rev option seems to only have effect when configured on developers' local machine.

One needs to pass commit sha1 either directly on command line or in a specific file in order for this to work.

I cannot modify your local git config, all I can do is include .git-blame-ignore-revs file with the commit id that is the subject of this PR. The question is how badly you need this 😁 ?

I was thinking about creating this .git-blame-ignore-revs file and putting hash of the reformatting commit there. But I actually can live without it, if we don't want to do this 😅

szmktk commented 3 months ago

We do, at least I'm curious to try it - so I've added the file. It indeed seems to work if you invoke git blame like this: git blame manage.py --ignore-revs-file .git-blame-ignore-revs Then you'll see git blame unaffected by commit 230a2a9. I don't know yet how to configure an editor to respect this setting, but we can figure it out together in-person 😉