Skip to content

[feature request] Support ignore block of code with noqa #3711

@woile

Description

@woile

First of all, thank you so much for this tool, it's fantastic 🚀 !

I would like to request the possibility to support ignoring a block of code. To my surprise, this is a feature some people have needed as well from flake8, see SO question, though it is not supported.

In my current use case, I have a bunch of templates, that are too long, and it becomes cumbersome to add noqa to all of them.

I was wondering if adding something like this would be possible (maybe with a different syntax):

# ruff: noqa: on: E501
TEMPLATE = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sit amet ligula magna. Nulla ${var1} vehicula leo, eget tincidunt leo pharetra in. Ut egestas felis et vehicula commodo. Aliquam ${var2} placerat tortor sed magna faucibus facilisis ut et mauris. Maecenas vitae sem augue. Cras egestas felis nulla, id porta nisl ${var3} vel
"""
# ruff: noqa: off: E501

Suggested changes

  • Add section-level suppression/ignoring of rules (ruff: noqa: on and ruff: noqa: off)
  • Add scope-level suppression/ignoring of rules (matches pylint block disables)

Thanks!

Sub-issues

Metadata

Metadata

Assignees

Labels

suppressionRelated to supression of violations e.g. noqa

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions