ruff icon indicating copy to clipboard operation
ruff copied to clipboard

D301 breaks Click docstrings that use the \b escape sequence

Open ThiefMaster opened this issue 2 years ago • 3 comments

Click uses \b to prevent re-wrapping: https://click.palletsprojects.com/en/8.1.x/documentation/#preventing-rewrapping

Maybe this rule could detect if it's a function docstring that has a @click.* decorator on it, or have a setting that whitelists certain escape sequences.

ThiefMaster avatar Nov 15 '23 15:11 ThiefMaster

click docs reference:

\b:

https://click.palletsprojects.com/en/8.1.x/documentation/#preventing-rewrapping Rewrapping can be disabled on a per-paragraph basis by adding a line with solely the \b escape marker in it.

\f:

https://click.palletsprojects.com/en/8.1.x/documentation/#truncating-help-texts You can use the \f escape marker to have Click truncate the help text after the marker.

deadnews avatar Feb 19 '24 19:02 deadnews

There's ignore-decorators but that requires the fully qualified name and won't work with globs. For now you could try the following config which, as per my limited knowledge of click, should be enough:

[tool.ruff.lint.pydocstyle]
ignore-decorators = [
	"click.group",
	"click.command",
	"click.argument",
	"click.option",
]

Playground: https://play.ruff.rs/2a18cbd2-c90a-4416-b19c-f969e688777b

dhruvmanila avatar Feb 21 '24 07:02 dhruvmanila

@dhruvmanila But this ignores docstrings completely. Specific # noqa: D301 is better.

deadnews avatar Feb 21 '24 08:02 deadnews