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

Use ruff to format/lint the codebase #136

Closed
wants to merge 11 commits into from
Closed

Conversation

johannaengland
Copy link
Contributor

@johannaengland johannaengland commented Sep 9, 2024

It is not possible yet to use the ruff formatter in MegaLinter, therefore I have set up to do the formatting and linting using ruff directly.

This also removes use of flake8 in pre-commit.

When this PR is approved I will squash all the fixing of the linting rules and the formatting to one commit and then add this commit to .git-blame-ignore-revs.

Also then I can change the workflow to only format/lint the changed files.

@johannaengland johannaengland added the after-demo Need not work for demo label Sep 9, 2024
@johannaengland johannaengland self-assigned this Sep 9, 2024
@hmpf hmpf removed the after-demo Need not work for demo label Sep 13, 2024
@podliashanyk
Copy link
Contributor

For #40

@@ -0,0 +1,2 @@
# Format codebase using ruff @johannaengland 09/09/2024
07fcc0fa89e719a7cd00d36a3f12e3b552ac6ef2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Code is added to this repo by squashing so this will not be correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I am aware, I was not planning on merging it like this, I just added this commit to not forget about it later

@hmpf hmpf self-requested a review October 7, 2024 09:09
Copy link
Collaborator

@hmpf hmpf left a comment

Choose a reason for hiding this comment

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

This needs splitting into at least two PR's, isort adds much noise. I'll spread this into several direct pushes and then this PR can be rebased to add the github actions.

Btw, have you remembered to set up pre-commit? It's already configured. There are newlines missing from several files.

Copy link
Contributor

@elfjes elfjes left a comment

Choose a reason for hiding this comment

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

I like it. the ignore-rev can be fixed by

  1. squash all non-formatting commits
  2. format everything in 1 commit
  3. add that commit to .git-blame-ignore-revs
  4. force push and FF-merge to main

@elfjes
Copy link
Contributor

elfjes commented Oct 7, 2024

Also: next step would be linting/formatting of templates (djlint?) and perhaps js/css?

@johannaengland
Copy link
Contributor Author

Also: next step would be linting/formatting of templates (djlint?) and perhaps js/css?

#137

@hmpf
Copy link
Collaborator

hmpf commented Oct 7, 2024

I have pushed the ruff-ed code to main with the correct hash in .git-blame-ignore-revs.

I have not removed the flake8 rule in pre-commit, and I am not linting in pre-commit right now.

I would like to see one PR that sets up github actions for this. Let's wait with isort, it has a *very' low priority and I Have Opinions™, I want to play with isort config options and how they interact with ruff before I let it loose on anything.

@hmpf
Copy link
Collaborator

hmpf commented Oct 7, 2024

We should have a changelog on this somewhere as it is very relevant for developers. I have found two handy flags when using "git blame":

[blame]
        markIgnoredLines = true
        markUnblamableLines = true

Try it and see with one of the files that has been ruffed.

I like what they do, they should be mentioned in the changelog but not in notes.

@johannaengland
Copy link
Contributor Author

This has been mostly replaced by #176 and #175. Other PRs to bit by bit introduce more linting rules might follow soon.

@johannaengland johannaengland deleted the workflows/ruff branch October 17, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants