Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RUF051] Formatting issue for description of if-key-in-dict-del (RUF051) in docs #14976

Closed
echoix opened this issue Dec 14, 2024 · 1 comment · Fixed by #14980
Closed

[RUF051] Formatting issue for description of if-key-in-dict-del (RUF051) in docs #14976

echoix opened this issue Dec 14, 2024 · 1 comment · Fixed by #14980
Labels
documentation Improvements or additions to documentation

Comments

@echoix
Copy link
Contributor

echoix commented Dec 14, 2024

In the new rule if-key-in-dict-del (RUF051), there seems to be a formatting issue, as shown in the following screenshot.
Image

I don't see the problem in the PR that seems to have added that text: https://github.com/astral-sh/ruff/pull/14553/files#diff-b0fd57331d4ce41cac2a70091108b4053b5514a06d5d75da3b6bb0e880fbaeb0R11-R16

What is different from other rules that don't show up like this?

@dylwil3
Copy link
Collaborator

dylwil3 commented Dec 14, 2024

Good catch! My guess is that mkdocs does not like the backticks that it's pulling out for the description? (That description/tag is auto-generated by a script based on the doc-comment).

@dylwil3 dylwil3 added the documentation Improvements or additions to documentation label Dec 14, 2024
Glyphack pushed a commit to Glyphack/ruff that referenced this issue Dec 15, 2024
## Summary

Resolves astral-sh#14976.

Currently, we uses this "[plain
scalar](https://yaml.org/spec/1.2.2/#733-plain-style)" format:

```yaml
description: Checks for `if key in dictionary: del dictionary[key]`.
```

Plain scalar must not contain the sequence `: `, however, so the above
is invalid.

This PR changes that to:

```yaml
description: |-
  Checks for `if key in dictionary: del dictionary[key]`.
```

`|` denotes a "[block
scalar](https://yaml.org/spec/1.2.2/#81-block-scalar-styles)", whereas
[the `-` chomping
indicator](https://yaml.org/spec/1.2.2/#8112-block-chomping-indicator)
requires that a trailing newline, if any, must be stripped.

## Test Plan


![](https://github.com/user-attachments/assets/f00b606a-d6fe-46ac-a1c5-6a8665204ea3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants