-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Format code with Ruff #221
base: master
Are you sure you want to change the base?
Conversation
@nutti, would you prefer a line-length other than 88? |
Thank you for your continuous work. I will check them. |
No problem, as long as it is the first PR you merge, it is fine as there will not be any merge conflict. |
Thank you for being active, I am really glad seeing this project moving forward and being part of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review.
I left some comments.
@@ -114,7 +115,8 @@ def test_append_child(self): | |||
<return> | |||
<description> | |||
<data-type-list> | |||
""") | |||
""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comma needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but the Ruff formatter cannot be configured not to add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding a comma at the last of the parameters makes us difficult to distinguish between set and the function parameter.
How do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comma is added automatically when there are more than one parameter.
The purpose of this rule is to minimize the diff in commits when adding or removing or switching parameters.
I am not bothered by it.
I prefer having an auto-formatter than not at all.
This allows focusing on code instead of formatting text manually.
This is really useful when format run on save.
Even if the style is less good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I understood your idea.
However, adding comma is not intuitively for the reader perspective.
Is it possible to disable this format even if other commas (including list, set, and so on) do not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think configuration file can select it like sphinx project.
https://github.com/sphinx-doc/sphinx/blob/master/.ruff.toml
https://docs.astral.sh/ruff/rules/trailing-comma-on-bare-tuple/
https://docs.astral.sh/ruff/configuration/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a linter rule not a formatter config.
The linter and formatter of Ruff are independent.
They do not influence each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my understanding, this PR targets to introduce Ruff linter not format the code.
Please consider to filter the error code by using the configuration file.
We could not accept this PR if it affects the readability.
It is important to keep the readability more than usefulness who does not introduce Ruff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be configurable from the editor.
I would like to filter the error to meet this project before merging this PR.
I found there is a format configuration. This doesn't work in your environment?
https://github.com/astral-sh/ruff-vscode?tab=readme-ov-file#configuring-ruff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a formatter configuration.
https://docs.astral.sh/ruff/formatter/#configuration
I think skip-magic-trailing-comma
can solve this issue.
https://docs.astral.sh/ruff/settings/#format_skip-magic-trailing-comma
Maybe, we should consider other rules as well.
a4f2b49
to
ed3a703
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @JonathanPlasse for updating this PR.
I have an additional comments.
Currently, build test for latest version will be failed. |
a04a049
to
659b85d
Compare
659b85d
to
067b9ef
Compare
I'm now experimenting the ruff linter. |
Indeed, I do not think the Ruff formatter fit this project. |
Thank you for your consideration. |
This requires a time to finish. |
Yes, you can close the pull request. |
Purpose of the pull request
Description about the pull request
# fmt: skip
where we want to keep manual formatting (e.g. Blender version)