Skip to content

--add-noqa for diagnostics on blank lines results in bad whitespace #23751

@amyreese

Description

@amyreese

Summary

Rules like D100 can produce diagnostics on TextRange::ZERO even if the line is blank. In these cases, running ruff with --add-noqa produces a line with leading whitespace:

Create an empty file, and run ruff check --add-noqa:

$ echo "" > test.py

$ ruff check --isolated --select D100 --add-noqa test.py
Added 1 noqa directive.

$ cat test.py
  # noqa: D100

Version

main

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsuppressionRelated 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