question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

The docstring reads

https://github.com/pandas-dev/pandas/blob/9ab55b4aed9018b070c939ffbdf232f99bf50f1a/scripts/validate_unwanted_patterns.py#L355-L361

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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
datapythonistacommented, Apr 12, 2021

Seems to me that these two last elif should 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.

0reactions
ShaharNavehcommented, Apr 12, 2021

Seems to me that these two last elif should be just one checking the end of the first line, and the start of the second. Doesn’t make much sense this way.

IIRC the reason for those two elif was 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 😅

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 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found