STYLE "wrongplaced whitespace" rule doesn't error on its example of a bad string
See original GitHub issueThe docstring reads
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 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
ESLint : Fast way to solve "Irregular whitespace not allowed"
You can use the extension fix-irregular-whitspace for vscode. It works by replacing all non breaking space from your code with a normal space....
Read more >How is the first example of compliant more error prone for ...
Stated another way, the length of a string includes whitespace, so isNullOrWhitespace won't be checking for name.Length > 0 . StingyJack (Andrew ...
Read more >Whitespace in a numeric field (EDI Data) does not error ... - IBM
When processing a file of EDI Delimited Data, and field which is coded as a Number in its validation tab contains only a...
Read more >pandas code style guide — pandas 1.1.5 documentation
Only put white space at the end of the previous line, so there is no whitespace at the beginning of the concatenated string....
Read more >[Review] SE-0168: Multi-Line String Literals - Swift Forums
I still feel that having the position of the closing delimiter determine how much whitespace is de-indented is not very natural or intuitive,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Seems to me that these two last
elifshould be just one checking the end of the first line, and the start of the second. Doesn’t make much sense this way.But in any case, that was added for some case that wasn’t working with the simple validation of
if the space is not at the end of the first line instead of at the beginning of the second, then fail. So, if there is nothing in our code now that fails with that simple condition, agree that better to remove.IIRC the reason for those two
elifwas to be as explicit as possible, in order to cover as much cases as possible I guess it slipped from me that they are not really useful 😅IIRC they did catch something in the codebase back then, but that was a year ago, I’m not really sure. Any way, I think it would be better to remove them, as long as they don’t seems to be needed. You can always add them again whenever you want.