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 for formatting #133

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Use ruff for formatting #133

wants to merge 3 commits into from

Conversation

rnestler
Copy link
Member

@rnestler rnestler commented Jun 3, 2024

This is just a quick PR to answer the following questions:

  • Should we add a code format check to CI?
  • Is the configuration like this OK?
  • Should we reformat the whole repo?
  • Should we also replace flake8 with ruff?

line-length = 120

[tool.ruff.format]
quote-style = "single"
Copy link
Member Author

Choose a reason for hiding this comment

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

I saw that we currently use a lot of 'foo' style strings instead of the ruff default "bar" strings.

@@ -46,5 +47,12 @@ balanced_wrapping = false
known_typing = "typing"
sections = "FUTURE,STDLIB,TYPING,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"

[tool.ruff]
target-version = "py38"
line-length = 120
Copy link
Member Author

Choose a reason for hiding this comment

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

IMO 120 is quite long, but isort was configured like this.

Copy link
Member

Choose a reason for hiding this comment

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

For me 120 feels quite long too, generally I prefer 80 (or max. 100).

Copy link
Member

Choose a reason for hiding this comment

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

I think 100 is the sweet spot.

@rnestler rnestler requested review from dbrgn and ubruhin and removed request for dbrgn June 3, 2024 10:34
Copy link
Member

@ubruhin ubruhin left a comment

Choose a reason for hiding this comment

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

I have no clear opinion about this. Generally I like consistent and enforced formatting and also the style looks quite good to me. But especially some configuration lists (e.g. FetConfig or ChipConfig) are getting more verbose / harder to read. Though not too bad I guess 🤔 Anyway, I would prefer a shorter line length.

Btw I never hear of ruff, so no opinions about that tool 😉

@@ -46,5 +47,12 @@ balanced_wrapping = false
known_typing = "typing"
sections = "FUTURE,STDLIB,TYPING,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"

[tool.ruff]
target-version = "py38"
line-length = 120
Copy link
Member

Choose a reason for hiding this comment

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

For me 120 feels quite long too, generally I prefer 80 (or max. 100).

'https://www.diodes.com/assets/Datasheets/DMC6040SSDQ.pdf',
]),

FetConfig(
Copy link
Member

Choose a reason for hiding this comment

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

In places like these I'd suppress the formatter... Is there a way to disable ruff for a block of code (using a stop / start command)?

Copy link
Member Author

Choose a reason for hiding this comment

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

One can just add # fmt: off / on pairs.

@dbrgn
Copy link
Member

dbrgn commented Jun 24, 2024

I'm a fan of autoformatters, as long as they allow sufficient control and can be disabled for certain parts of the code if necessary. So +1 from my side for ruff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants