Skip to content

STYLE "wrongplaced whitespace" rule doesn't error on its example of a bad string #40873

Closed
@MarcoGorelli

Description

@MarcoGorelli

The docstring reads

For example, this is bad:
>>> rule = (
... "We want the space at the begging of "
... "the line if the previous line is ending with a \n "
... "not at the end, like always"
... )

yet this file doesn't error if the script is run on it:

$ cat t.py 
rule = (
   "We want the space at the begging of "
   "the line if the previous line is ending with a \n "
   "not at the end, like always"
)
$ python scripts/validate_unwanted_patterns.py -vt 'strings_with_wrong_placed_whitespace' t.py 

Some other files which don't error, though I can't understand why:

$ cat t.py 
rule = (
   "  We want the space at the begging of"
   " the line if the previous line is ending with a \n "
   "not at the end, like always"
)
$ python scripts/validate_unwanted_patterns.py -vt 'strings_with_wrong_placed_whitespace' t.py 
$ cat t.py 
rule = (
   "We want the space at the begging of"
   " the line if the previous line is ending with a  "
   "not at the end, like always"
)
$ python scripts/validate_unwanted_patterns.py -vt 'strings_with_wrong_placed_whitespace' t.py

Hi @ShaharNaveh @datapythonista - do you have any context you could provide on the trailing newline rule? I'm struggling to make sense of it - thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code StyleCode style, linting, code_checks

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions