-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a check to raise error on missing whitespace around arithmetic … #1143
Added a check to raise error on missing whitespace around arithmetic … #1143
Conversation
@@ -2876,6 +2876,10 @@ Release date: 2003-09-12 | |||
|
|||
* easy functional test infrastructure | |||
|
|||
* Raise bad-whitespace error on arithmetic operators that miss spaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check the indentation here? Seems to use tabs or it has too many spaces. Also, this uses the wrong section for the release, it should be the latest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, mind adding a new entry in What's New as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added it in the right location. Is that it? Or should it be added any where else too?
@@ -0,0 +1,8 @@ | |||
# pylint: disable=missing-docstring,invalid-name,unused-argument | |||
def sample_function(*args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this behave to operator with different priorities? For instance, PEP 8 recommends something as x = x*2 - 1
instead of x = x * 2 - 1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pep8 throws an E226
error on a = a*4 + 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contradicting to the statement in the documentation
https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW pycodestyle (which is what pep8 was renamed to) has E226 disabled by default. I think having it enabled by default in pylint would be a mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, should we have a separate error message for this which is disabled by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be made to work with some tweaking. I think this makes sense in the cases where both operands are not BinOp
s and neither is the parent (with the exception of being the RHS in a AssignTypeMixin
). This would catch x = a*4
but allow a = a*4 + 2
. What do you think @PCManticore @The-Compiler ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rowillia sure I will try it out.. Can you please explain a bit?
@aswinm Did you see my comment here - #1143 (comment) . Is this something you think you could try out? As is, as @PCManticore pointed out this linter would not comply with PEP8. |
Thank you for the pull request @aswinm I decided to close this issue. This is a PEP 8 rule that is not unanimously accepted and, as @The-Compiler mentioned already, |
Fixes / new features
Fix for issue #1110