This PR implements `W505` (`DocLineTooLong`), which is similar to `E501` (`LineTooLong`) but confined to doc lines. I based the "doc line" definition on pycodestyle, which defines a doc line as a standalone comment or string statement. Our definition is a bit more liberal, since we consider any string statement a doc line (even if it's part of a multi-line statement) -- but that seems fine to me. Note that, unusually, this rule requires custom extraction from both the token stream (to find standalone comments) and the AST (to find string statements). Closes #1784.
16 lines
429 B
Python
16 lines
429 B
Python
#!/usr/bin/env python3
|
|
"""Here's a top-level docstring that's over the limit."""
|
|
|
|
|
|
def f():
|
|
"""Here's a docstring that's also over the limit."""
|
|
|
|
x = 1 # Here's a comment that's over the limit, but it's not standalone.
|
|
|
|
# Here's a standalone comment that's over the limit.
|
|
|
|
print("Here's a string that's over the limit, but it's not a docstring.")
|
|
|
|
|
|
"This is also considered a docstring, and is over the limit."
|