Skip to content
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

Closed

Conversation

aswinm
Copy link

@aswinm aswinm commented Oct 21, 2016

Fixes / new features

  • Adding a check for spaces aroud arithmetic operators.

Fix for issue #1110

@@ -2876,6 +2876,10 @@ Release date: 2003-09-12

* easy functional test infrastructure

* Raise bad-whitespace error on arithmetic operators that miss spaces
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Author

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):
Copy link
Contributor

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.

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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.

Copy link
Author

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?

Copy link
Contributor

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 BinOps 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 ?

Copy link
Author

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?

@rowillia
Copy link
Contributor

rowillia commented Dec 2, 2016

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

@PCManticore
Copy link
Contributor

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, pycodestyle, another popular analysis tool, tailored more to PEP 8 than pylint is ever going to be, has this rule disabled by default. I'm afraid I don't see the benefit of having all the PEP * rules integrated in pylint. Thanks again for your effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants