-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Summary
The docs for E501 states that "a line will not be flagged as overlong if a pragma comment causes it to exceed the line length."
This works if the comment is # noqa, but seems to fail if there's any other preceding # (with some exceptions for # type: ignore, see below).
Reproducible with source:
def foo(arg=True):... ## noqa: FBT002and settings:
{
"line-length": 35,
"lint": {
"select": [
"E501",
"FBT"
]
},
"format": {}
}The practical real-world use-case for this is when multiple linting tools and ignore comments are used, e.g. adding # noqa here where the line was previously not too long will cause a violation (but should not):
# numpydoc ignore=PR01 # noqa: FBT002
Interestingly, the # type: ignore case is handled properly, and does not cause a violation:
# type: ignore # noqa: FBT002
Version
ruff v0.11.12 (using the ruff playground)
EDIT: For clarity:
This line is not too long:
def foo(arg=True):... #But this line is:
def foo(arg=True):... ## noqa: FBT002But, simply adding # noqa: FBT002 should not cause the line to be too long.