cpython icon indicating copy to clipboard operation
cpython copied to clipboard

bpo-24612: Improve syntax error for 'not' after an operator

Open pablogsal opened this issue 2 years ago • 7 comments

https://bugs.python.org/issue24612

pablogsal avatar Sep 04 '21 21:09 pablogsal

It introduces misleading errors:

>>> not 1 */ 2
  File "<stdin>", line 1
    not 1 */ 2
    ^^^^^
SyntaxError: 'not' after an operator must be parenthesized

serhiy-storchaka avatar Sep 05 '21 06:09 serhiy-storchaka

>>> not 1 +
  File "<stdin>", line 1
    not 1 +
    ^^^^^
SyntaxError: 'not' after an operator must be parenthesized

serhiy-storchaka avatar Sep 05 '21 06:09 serhiy-storchaka

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

pablogsal avatar Sep 05 '21 13:09 pablogsal

This PR is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Oct 06 '21 00:10 github-actions[bot]

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

bedevere-bot avatar Dec 06 '22 23:12 bedevere-bot

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?

encukou avatar Mar 20 '24 13:03 encukou

Do you want to add that to this PR?

Done.

lysnikolaou avatar Mar 21 '24 09:03 lysnikolaou

Thank you!

encukou avatar Mar 26 '24 09:03 encukou