ruff
ruff copied to clipboard
Bad fixes with E266: multiple-leading-hashes-for-block-comment
I'm trying out --preview with ruff 0.3.4. E266 which is a pycodestyle --preview rule has some weird fixes:
- Probably should try to leave headers alone if the comment ends in one or more
#
-##################################### FOO #############################################
+# FOO #############################################
- Why is the space after the
:?
- #:::team.foo.bar.baz
+ #: ::team.foo.bar.baz
- Weird example in https://docs.astral.sh/ruff/rules/multiple-leading-hashes-for-block-comment/#example
Use instead:
# Block comments:
# - Block comment list
# \xa0- Block comment list
-
I think flagging it (and the way its fixed) is in line with the intent of the rule. You might want to disable
E266if you want to keep header comments with this specific format. -
Pycodestyle both allows
:or!directly after the#
#: E265:2:1
m = 42
#! This is important
mx = 42 - 42
#: E266:3:5 E266:6:5
- I assume what you find weird about it is the
\xa0? Or is it something else
Pycodestyle also allows this style for headers:
#####
# Foo
#####
That is, lines that are only # are allowed.
Thanks for the clarifications!
- Probably should try to leave headers alone
TIL about the pycodestyle suggested header style, thanks. IMO since PEP 8 doesn't specify a header style, tools should be more permissive (but I understand the desire for compatibility with pycodestyle)
- Why is the space after the :?
Pycodestyle both allows : or ! directly after the #
- TIL that
#:is for sphinx documentation, but the fact that pycodestyle supports this is undocumented. - FYI for
#!: pycodestyle does not allow#! comment(except for shebangs on the first line) -- these comments result inE265 block comment should start with '# '
- Weird example in https://docs.astral.sh/ruff/rules/multiple-leading-hashes-for-block-comment/#example
I assume what you find weird about it is the \xa0? Or is it something else
- the
\xa0is weird and - the "use instead" doesn't seem to follow from the "example" E.g. perhaps instead it should be
Example
### Public API
def say_hi():
## This is a block comment.
print("hi")
Use instead
# Public API
def say_hi():
# This is a block comment.
print("hi")
or
Use instead
#############
# Public API
#############
def say_hi():
# This is a block comment.
print("hi")