comments¶
What this rule does¶
Controls formatting of # comments — whether a space is required
after the #, and how far inline comments must sit from preceding
content.
Why this matters¶
- Legibility.
#commentand# commentread very differently; enforcing a space keeps comments visually distinct from directive-like prefixes. - Inline comments. Pushing inline comments away from values prevents visual collisions when values change length.
Configuration¶
[rules.comments]
level = "error"
require-starting-space = true
ignore-shebangs = true
min-spaces-from-content = 2
| Option | Default | Description |
|---|---|---|
require-starting-space |
true |
Require at least one space between # and the comment text. |
ignore-shebangs |
true |
Skip #! shebang lines when require-starting-space is on. |
min-spaces-from-content |
2 |
Minimum spaces between code and an inline # comment. Use -1 to disable. |
Examples¶
Allowed (defaults)¶
Reported (defaults)¶
After ryl --fix¶
Automatic fixing¶
ryl --fix inserts the missing space after # and pads inline comments
to the configured min-spaces-from-content. Disable with:
Related rules¶
comments-indentation— controls the vertical alignment of standalone comments.