-
-
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
False positive superfluous-parens #4907
Comments
similar regression since 2.10 version with the following example: def __iter__(self):
return ( (k, getattr(self, k)) for k in self.keys ) |
@Pierre-Sassoulas This is the result of the following tests and my implementation of solving these in #4784 B = [x for x in ((3, 4))] # [superfluous-parens]
C = [x for x in ((3, 4) if 1 > 0 else (5, 6))]
D = [x for x in ((3, 4) if 1 > 0 else ((5, 6)))] # [superfluous-parens]
E = [x for x in ((3, 4) if 1 > 0 else ((((5, 6)))))] # [superfluous-parens] Looking at these two reports perhaps these are valid cases of double parens and should be removed from the tests, as well as removing from if contains_double_parens and tokens[i + 1].string == ")":
self.add_message(
"superfluous-parens", line=line_num, args=keyword_token
)
return
contains_double_parens = 0
continue |
I think I hit this issue as well, with this code block, altough with the import numpy as np
def _function_one(var_1: int, var_2: int) -> np.ndarray:
result = (((var_1 & var_2)) > 0)
return result.astype(np.float32) # no problem
def _function_two(var_1: int, var_2: int) -> np.ndarray:
return (((var_1 & var_2)) > 0).astype(np.float32) # Error: Unnecessary parens after 'return' keyword (superfluous-parens)
|
@Pierre-Sassoulas I think you might have missed this. I believe this should be part of 2.11 as it was introduced in 2.10 and is easily fixable (if we do agree that this part of the check should be removed). |
Right, thank you for reminding me. The suggestion in your previous comment makes sense. |
Tuples can be created with inner tuples. This creates double parenthesis which we flagged incorrectly. This closes pylint-dev#4907
Tuples can be created with inner tuples. This creates double parenthesis which we flagged incorrectly. This closes pylint-dev#4907
Tuples can be created with inner tuples. This creates double parenthesis which we flagged incorrectly. This closes #4907
I hit this issue too at https://github.com/mesonbuild/meson/blob/dc51740e2cdee171ac6ebc7ed261e5c08730c9a9/mesonbuild/dependencies/mpi.py#L150-L152 return (f.startswith(('-L', '-l', '-Xlinker')) or
f == '-pthread' or
(f.startswith('-W') and f != '-Wall' and not f.startswith('-Werror'))) The parentheses are needed for grouping, the alternative is a syntax error. This doesn't appear to have been mentioned already in this bug, and it's fixed by the linked ticket, but there doesn't seem to be a test explicitly covering this. Maybe there should be? |
Yeah, this seems like something different than any of our other tests! I will add an test when I get around to it! |
Additional test based on a suggestion in pylint-dev#4907
Additional test based on a suggestion in #4907
Bug description
Command used
Pylint output
Expected behavior
No errors.
Pylint version
OS / Environment
Ubuntu 20.04.3 LTS
The text was updated successfully, but these errors were encountered: