Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
E225 should not require whitespace surrounding higher-precedence operators #166
Comments
|
This is a duplicate of issue #96, released with version 1.4 |
florentx
closed this
Feb 15, 2013
eZanmoto
commented
Feb 23, 2013
|
I must have been using an older version of the binary, however, the fix still does not allow an absence of whitespace around all higher-precedence operators in an expression, the rule seems to just be a context-unaware "allow optional spacing around
This should also mean that all operators inside parentheses may omit whitespace. I currently have an issue where the following statement is signalling E225 (missing whitespace around operator):
I believe that this format for the expression should be allowed, as I have omitted the spacing for the higher precedence expression (that inside parentheses), and including the spacing for the lower precedence expression. |
|
I confirm that since The whitespace is still mandatory (emitting
The reason for this choice is that all these operators bind less tightly than the arithmetic operators (except the modulo IMHO in this example the parenthesis is enough to signal that the operation binds more tightly: def f(byte, bit):
return (byte >> bit) & 1I agree that the PEP-8 specification give even more freedom regarding the whitespace around these non-arithmetic operators, however the current logic of the I re-open the issue in case someone else wants to comment on this request. |
florentx
reopened this
Feb 23, 2013
eZanmoto
commented
Feb 23, 2013
While they are equal in the fact that they bind less tightly than arithmetic operators, they still have different levels of precedence relative to each other, and though the examples on PEP8 only alude to arithmetic operators, the actual wording of the rule imposes such restrictions. As such, I would imagine that the following would be allowed:
Also, consider the following snippet I presented earlier:
The reason I would advocate this style over having whitespace surrounding the
Over the inclusion of whitespace (the following is titled "No"):
While I personally prefer the style of simply surrounding all binary operators with a single space, I follow the idea that one should follow an idiomatic style if one is presented, and such is why I'm pushing this issue. |
added a commit
that referenced
this issue
Feb 24, 2013
|
This should give enough flexibility to ignore the verification for |
|
released with 1.4.4 |
eZanmoto commentedFeb 14, 2013
At the moment, pep8 will signal an error for all of the following (defined in PEP8 as examples that should be allowed):
This behaviour conflicts with the following convention preceding these lines in PEP8:
If coding this rule is too complex for immediate implementation, I would suggest loosening the rule for the time being, so that the rule simply makes sure that there are is at most 1 space between operators and their operands.