PY-84077 - Support PEP 758 – Allow except and except* expressions without parentheses

- adjust parser to support comma separated list of error classes
- add problem annotation and quick fix for missing parentheses
- add new tests, adjust old tests

GitOrigin-RevId: a1b9bdf252ac874aa7bd1a6881c1784259bb35cc
This commit is contained in:
Marcus Mews
2025-09-15 08:33:03 +00:00
committed by intellij-monorepo-bot
parent 2cf790a9d6
commit 63abd60ba4
11 changed files with 150 additions and 35 deletions
@@ -0,0 +1,5 @@
def f():
try:
pass
except <error descr="Parentheses are required when specifying a target for multiple exception classes">ValueError, TypeError</error> as e:
pass
@@ -0,0 +1,4 @@
try:
pass
except ImportError,<caret> AccessError as e:
pass
@@ -0,0 +1,4 @@
try:
pass
except (ImportError, AccessError) as e:
pass
+8 -2
View File
@@ -1,9 +1,15 @@
# try and friends
<stmt>try:
p<body>ass
e<ex1>xcept ArithmeticError, e:
e<ex0>xcept ArithmeticError:
pass
e<ex2>xcept:
e<ex1>xcept ArithmeticError, ImportError:
pass
e<ex2>xcept ArithmeticError as e2:
pass
e<ex3>xcept (ArithmeticError, ImportError) as e3:
pass
e<ex4>xcept:
pass
e<else>lse:
pass