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

Auto-format Python code with ruff format #23154

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Dec 13, 2024

Fixes: #14449

Use ruff format to format Python code. https://docs.astral.sh/ruff/formatter

Settings in pyproject.toml are all subject to discussion:

format.quote-style = "preserve"
indent-width = 2
line-length = 120
  • Add a ruff format command after the existing ruff check test in CircleCI.
  • Remove .style.yapf because maintainers should agree on a single Python code formatter.
  • Format suppression: comments can be used to preserve formatting. # fmt: off and # fmt: on

Any hints on the CircleCI: build-docs failure?

@@ -407,8 +407,7 @@ def metafunc(self, fs, *args, **kwargs):
assert fs is None
func(self, *args, **kwargs)

parameterize(metafunc, {'': (None,),
'nodefs': ('nodefs',)})
parameterize(metafunc, {'': (None,), 'nodefs': ('nodefs',)})
Copy link
Collaborator

Choose a reason for hiding this comment

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

All of these uses of parameterize are deliberately spread so that there is one test case per line. Its important for readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the format suppression comment in the commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a trailing comma after the last dict item will cause ruff format to make things clear.

Suggested change
parameterize(metafunc, {'': (None,), 'nodefs': ('nodefs',)})
parameterize(
metafunc,
{
'': (None,),
'nodefs': ('nodefs',),
},
)

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

Successfully merging this pull request may close these issues.

Auto-format Python code
2 participants