cpython
cpython copied to clipboard
bpo-24612: Improve syntax error for 'not' after an operator
https://bugs.python.org/issue24612
It introduces misleading errors:
>>> not 1 */ 2
File "<stdin>", line 1
not 1 */ 2
^^^^^
SyntaxError: 'not' after an operator must be parenthesized
>>> not 1 +
File "<stdin>", line 1
not 1 +
^^^^^
SyntaxError: 'not' after an operator must be parenthesized
@serhiy-storchaka I have adapted the rule and added some extra tests, although I am a bit suspicious that this will be a bit tricky to get fully right.
This PR is stale because it has been open for 30 days with no activity.
When you're done making the requested changes, leave the comment: I have made the requested changes; please review again
.
Would it make sense to additionally add a rule that will catch this for unary ops?
Yes. Do you want to add that to this PR?
Do you want to add that to this PR?
Done.
Thank you!