wemake-python-styleguide icon indicating copy to clipboard operation
wemake-python-styleguide copied to clipboard

Feature: find extra parentheses that can be removed

Open sobolevn opened this issue 6 years ago • 3 comments

Rule request

Thesis

There are cases when parentheses can be removed. Like: x = ('string'). There are also examples when it can not be removed: x = (1 + 3) * 2

There are also cases when they should not be removed (since I prefer to use tuple with explicit parentheses): x = (1, 2).

Reasoning

This will increase consistency.

Format

This should be a separate plugin. Because I am sure that this will be impossible to achieve without logical_line param. Related: https://rules.sonarsource.com/python/RSPEC-1110

sobolevn avatar Oct 05 '18 17:10 sobolevn

Related:

  • https://gist.github.com/snoack/e78963516d93e55add32fc1f8237b0e4
  • https://stackoverflow.com/questions/56956892/how-to-check-for-redundant-parentheses-with-flake8

sobolevn avatar Sep 19 '19 19:09 sobolevn

Easy case: print((a))

sobolevn avatar Dec 05 '19 09:12 sobolevn

Or return ((a, b, c))

sobolevn avatar Dec 05 '19 20:12 sobolevn