nutti / fake-bpy-module

Fake Blender Python API module collection for the code completion.
MIT License
1.32k stars 95 forks source link

Switch to Ruff for CI #171

Closed JonathanPlasse closed 3 weeks ago

JonathanPlasse commented 7 months ago

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

nutti commented 7 months ago

@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.

JonathanPlasse commented 7 months ago

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.

nutti commented 7 months ago

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 commented 6 months ago

@JonathanPlasse

Is there any update?

JonathanPlasse commented 5 months ago

Should I go ahead adding Ruff?

nutti commented 5 months ago

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

nutti commented 2 months ago

@JonathanPlasse

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

JonathanPlasse commented 2 months ago

@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

nutti commented 2 months ago

@JonathanPlasse

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

JonathanPlasse commented 2 months ago

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

nutti commented 2 months ago

@JonathanPlasse

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

nutti commented 3 weeks ago

Ruff linter is now enabled for CI.

JonathanPlasse commented 3 weeks ago

Awesome