To make Black ignore a specific portion of your code, you can use the # fmt: off and # fmt: on comments.
Follow these steps:
- Add
# fmt: offbefore the section you want Black to ignore. - Write your code (the portion you don’t want Black to format).
- Add
# fmt: onafter the section you want Black to ignore.
Example:
In this example, the matrix array will not be formatted by Black, while the rest of the code will follow Black’s formatting rules.