PyCQA / pycodestyle

Simple Python style checker in one Python file
https://pycodestyle.pycqa.org
Other
5.01k stars 755 forks source link

E222: Disallow whitespace after unary negative? #941

Open PeterJCLaw opened 4 years ago

PeterJCLaw commented 4 years ago

Should pycodestyle disallow whitespace between a unary negation and its symbol?

foo = - 2
sigmavirus24 commented 4 years ago

Maybe. I can imagine if we disallowed that the scientific python community would be just as furious as every time they discover they can't visually align decimals inside a matrix. (I think I've even seen examples where they visually align the sign of the number so that vertically it looks like:

-  0.01,
  10.52,
-234.27,

Which I'm not endorsing as good general style, but I really don't want a tonne more issues from people complaining that we're making their code ugly.

PeterJCLaw commented 4 years ago

Hrm, I can definitely see a case for that style in the specific case of tabular data.

Is it not enough to for this to have its own error id which can then be opted in/out?

Trying out the case you're suggesting, there are a couple of other errors I get, so users would already need to be handling those:

fab = [
    -  0.01,
      10.52,
    -234.27,
]
demo.py:2:6: E222 multiple spaces after operator
demo.py:3:7: E131 continuation line unaligned for hanging indent

Though admittedly those errors don't show if the values are part of tuples rather than being on their own.