Skip to content

RUF035 (unsafe-markup-use) can be noisy and would benefit from a whitelist #14523

@ThiefMaster

Description

@ThiefMaster

There are a few cases where it does not really make sense to get the warning, since it's pretty clearly intentional to avoid escaping, but adding noqa comments in every place where it's used would be very noisy/verbose:

  • Markup(render_template(...))
  • Markup(_('Have a look at <strong>this</strong> translated string!'))
  • msg = _('Have a look at <strong>this</strong>!'); Markup(msg)

So ideally I'd like to have a setting where I can add function names (ideally as import strings, but just names would also be OK most of the time) to be considered safe to have their return value passed to Markdown - either directly or via a variable assignment.

In the above case, I'd expect all 3 warnings to disappear by whitelisting render_template and _.

Metadata

Metadata

Assignees

No one assigned

    Labels

    previewRelated to preview mode featuresruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions