mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
PY-84322 Code compatibility inspection doesn't warn about absent parentheses in except clauses in Python <3.14
- add incompatibility inspections, quickfix, tests - improve quickfix for adding parentheses - add AST tests for PY-84077 GitOrigin-RevId: 2d09a06d4d0b5ae106f556808900573c50f41800
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c1985c7eab
commit
9c2d77a961
@@ -1,4 +1,4 @@
|
||||
try:
|
||||
do_smth()
|
||||
<warning descr="Python versions 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14 do not support this syntax">except ImportError, ImportWarning:
|
||||
<warning descr="Python versions 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 do not support this syntax">except ImportError, ImportWarning:
|
||||
do()</warning>
|
||||
@@ -0,0 +1,4 @@
|
||||
try:
|
||||
pass
|
||||
<error descr="Python version 3.13 does not support this syntax">except IOError, OSError:
|
||||
pass</error>
|
||||
@@ -0,0 +1,4 @@
|
||||
try:
|
||||
pass
|
||||
except <warning descr="Different semantics of comma-separated elements in Python versions 2.7, 3.14.">IOError, OSError</warning>:
|
||||
pass
|
||||
@@ -0,0 +1,4 @@
|
||||
try:
|
||||
pass
|
||||
except <warning descr="Python version 3.7 does not support missing parentheses in except clauses">IOError, OSError</warning>:
|
||||
pass
|
||||
@@ -0,0 +1,4 @@
|
||||
try:
|
||||
f = open('myfile.txt')
|
||||
except IOError, OtherError: # same code as pre 314
|
||||
pass
|
||||
@@ -0,0 +1,39 @@
|
||||
PyFile:TryExceptMultipleNoParensPost314.py
|
||||
PyTryExceptStatement
|
||||
PyTryPart
|
||||
PsiElement(Py:TRY_KEYWORD)('try')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: open
|
||||
PyReferenceExpression: open
|
||||
PsiElement(Py:IDENTIFIER)('open')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyStringLiteralExpression: myfile.txt
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)(''myfile.txt'')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace('\n')
|
||||
PyExceptPart
|
||||
PsiElement(Py:EXCEPT_KEYWORD)('except')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTupleExpression
|
||||
PyReferenceExpression: IOError
|
||||
PsiElement(Py:IDENTIFIER)('IOError')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: OtherError
|
||||
PsiElement(Py:IDENTIFIER)('OtherError')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# same code as pre 314')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
@@ -0,0 +1,4 @@
|
||||
try:
|
||||
f = open('myfile.txt')
|
||||
except IOError, OtherError: # same code as post 314
|
||||
pass
|
||||
@@ -0,0 +1,38 @@
|
||||
PyFile:TryExceptMultipleNoParensPre314.py
|
||||
PyTryExceptStatement
|
||||
PyTryPart
|
||||
PsiElement(Py:TRY_KEYWORD)('try')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: open
|
||||
PyReferenceExpression: open
|
||||
PsiElement(Py:IDENTIFIER)('open')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyStringLiteralExpression: myfile.txt
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)(''myfile.txt'')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace('\n')
|
||||
PyExceptPart
|
||||
PsiElement(Py:EXCEPT_KEYWORD)('except')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: IOError
|
||||
PsiElement(Py:IDENTIFIER)('IOError')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: OtherError
|
||||
PsiElement(Py:IDENTIFIER)('OtherError')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# same code as post 314')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
@@ -0,0 +1,4 @@
|
||||
try:
|
||||
f = open('myfile.txt')
|
||||
except (IOError, OtherError):
|
||||
pass
|
||||
@@ -0,0 +1,40 @@
|
||||
PyFile:TryExceptMultipleWithParens.py
|
||||
PyTryExceptStatement
|
||||
PyTryPart
|
||||
PsiElement(Py:TRY_KEYWORD)('try')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: open
|
||||
PyReferenceExpression: open
|
||||
PsiElement(Py:IDENTIFIER)('open')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyStringLiteralExpression: myfile.txt
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)(''myfile.txt'')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace('\n')
|
||||
PyExceptPart
|
||||
PsiElement(Py:EXCEPT_KEYWORD)('except')
|
||||
PsiWhiteSpace(' ')
|
||||
PyParenthesizedExpression
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyTupleExpression
|
||||
PyReferenceExpression: IOError
|
||||
PsiElement(Py:IDENTIFIER)('IOError')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: OtherError
|
||||
PsiElement(Py:IDENTIFIER)('OtherError')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
Reference in New Issue
Block a user