fake-bpy-module icon indicating copy to clipboard operation
fake-bpy-module copied to clipboard

Switch to Ruff for CI

Open JonathanPlasse opened this issue 1 year ago • 11 comments

Description about the feature

Currently, this project use Pylint and Pycodestyle and does not seem to use any formatter. I propose to use Ruff to replace them and also use Ruff to format the project. It would also run faster.

Are you willing to contribute about this feature. (Yes/No)

Yes

JonathanPlasse avatar Dec 26 '23 21:12 JonathanPlasse

@JonathanPlasse

I think Ruff does not all formatting rules of Pylint and Pycodestyle. To support Pylint and Pycodestyle users, lint test with multiple linter tool is prefer.

nutti avatar Dec 27 '23 08:12 nutti

Currently, the generated code is not linted by Pylint. Why should the pyi files pass Pylint? Typeshed only use black and flake8-pyi to lint and format pyi files.

In my opinion, automatically generated code should be formatted and pass flake8-pyi and nothing else. Other linters could and should ignore the generated code.

Also, pycodestyle is totally implemented in Ruff and most important Pylint rules are implemented (cf. How does Ruff's linter compare to Pylint? and couple with a type checker like Pyright it pretty much cover all rules.

Finally, Ruff is fast so it can run in the editor without latency and it can auto-fix rule violations which is awesome.

JonathanPlasse avatar Dec 29 '23 16:12 JonathanPlasse

Actually, Pylint/pycodestyle is mainly used for checking the generation code under the src directory. We don't need to speed up the lint against these files as you can see.

But generated code is not in the same situation compared to the generation code. You can ignore the generated code from Pylint/pycodestyle check because we switched YAPF to Ruff.

nutti avatar Dec 30 '23 12:12 nutti

@JonathanPlasse

Is there any update?

nutti avatar Jan 21 '24 09:01 nutti

Should I go ahead adding Ruff?

JonathanPlasse avatar Feb 17 '24 11:02 JonathanPlasse

Adding Ruff is possible as a linter. But please do not delete the test of pylint and pycodestyle.

nutti avatar Feb 17 '24 12:02 nutti

@JonathanPlasse

Large refactoring was finished recently. You can work this with much more safely now.

nutti avatar May 11 '24 07:05 nutti

@JonathanPlasse

I think Ruff does not all formatting rules of Pylint and Pycodestyle. To support Pylint and Pycodestyle users, lint test with multiple linter tool is prefer.

@nutti, The Ruff linter that indeed do not have all formatting rules of Pylint and Pycodestyle, but with the Ruff formatter fix all these formatting rules.

I would like to at least add the Ruff formatter to format automatically the code and avoid having to manually format the code. We can use # fmt: skip to avoid auto formatting some code like the list of Blender version. Screenshot from 2024-05-19 10-48-44

JonathanPlasse avatar May 19 '24 08:05 JonathanPlasse

@JonathanPlasse

Yes, go ahead. BTW, why does these list codes need #fmt: skip? What is the proposal from ruff?

nutti avatar May 19 '24 10:05 nutti

It would format like this Screenshot from 2024-05-19 13-56-12

JonathanPlasse avatar May 19 '24 11:05 JonathanPlasse

@JonathanPlasse

Thank you for sharing. I think current format with #fmt: skip is much better. You can add it where you think better :)

nutti avatar May 19 '24 12:05 nutti

Ruff linter is now enabled for CI.

nutti avatar Jul 07 '24 01:07 nutti

Awesome

JonathanPlasse avatar Jul 07 '24 05:07 JonathanPlasse