You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more of an FYI for devs than an actual issue
Motivation
We changed to using Ruff instead of black and flake8 (#599 and pygfx/pygfx#859). The reason is that it provides a modern unified tool that provides several advantages: it's very fast, can be configured via pyproject.toml, has loads of linting rules, has support for auto-fixing some linting errors, and has good integration with VSCode and Github.
Adjusting workflows
My main concern with switching to Ruff is that it forces devs to adjust their workflow.
Ruff's formatting is nearly compatible with black. There are a few cases where they want to format code differently. I removed the 3 cases where this happened, but at some point someone will introduce such a case.
So, some tips:
New workflow (CLI commands)
black . -> ruff format
flake8 . -> ruff check
How to use Ruff and Black in VSCode
When you use VSCode, you may want to install the Ruff extension. Apart from formatting python file when you save them, you also get in-line linting errors (and sometimes options to autofix them).
When you already use the common Black Formatter extension, I found that the format-on-save stopped working if both extensions are active. A way to fix this is to disable the Ruff extension, and only in workspaces where you use ruff, you enable ruff and disable black. Or the other way around.
Or you can just keep using the Black Formatter extension, and make a habit to run ruff format before a push.
The text was updated successfully, but these errors were encountered:
This is more of an FYI for devs than an actual issue
Motivation
We changed to using Ruff instead of black and flake8 (#599 and pygfx/pygfx#859). The reason is that it provides a modern unified tool that provides several advantages: it's very fast, can be configured via pyproject.toml, has loads of linting rules, has support for auto-fixing some linting errors, and has good integration with VSCode and Github.
Adjusting workflows
My main concern with switching to Ruff is that it forces devs to adjust their workflow.
Ruff's formatting is nearly compatible with
black
. There are a few cases where they want to format code differently. I removed the 3 cases where this happened, but at some point someone will introduce such a case.So, some tips:
New workflow (CLI commands)
black .
->ruff format
flake8 .
->ruff check
How to use Ruff and Black in VSCode
When you use VSCode, you may want to install the
Ruff
extension. Apart from formatting python file when you save them, you also get in-line linting errors (and sometimes options to autofix them).When you already use the common
Black Formatter
extension, I found that the format-on-save stopped working if both extensions are active. A way to fix this is to disable theRuff
extension, and only in workspaces where you use ruff, you enable ruff and disable black. Or the other way around.Or you can just keep using the
Black Formatter
extension, and make a habit to runruff format
before a push.The text was updated successfully, but these errors were encountered: