I would like to disable/suppress the ruff linter (or certain linting rules) on a block of code. I know that I can do this for single lines (by using # noqa: <rule_code> at the end of the line) or for entire files/folder (#ruff: noqa <rule_code> at the top of the file).
However, I would like to disable the linter ruff on one function or on a multi-line block of code, but not an entire file. Is there a way to do this, without adding noqa to the end of each line?
Not currently possible (as of 29 Jan 2024). See here for updates on the issue
You did not specify this in your question, but if this is about ruff format, and you want to generally disable it for a block of code, you can actually do this using the fmt comment:
# fmt: off
def my_unformatted_function():
do_something()
# fmt: on
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With