mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
PY-44974 PEP 604: Support Python3.10 unions
Support | syntax for python unions. Also support type | None as a new style for Optional. Fix highlighting unresolved reference issues with | syntax. Type inference from isinstance and issubclass. Add quick fix to switch to old-style syntax in earlier python versions (<3.10) Fix quick documentation to render new syntax. (cherry picked from commit 6a64ee12c2d8503a0ef102e8b67cb0b95ce77999) IJ-MR-8400 GitOrigin-RevId: c26b868fc61f26936a3316ec06f78b66d75f6857
This commit is contained in:
committed by
intellij-monorepo-bot
parent
51f447141a
commit
ebe8f93812
+4
@@ -0,0 +1,4 @@
|
||||
class A:
|
||||
pass
|
||||
|
||||
assert isinstance(A(), <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y"><caret>int | str</warning>)
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class A:
|
||||
pass
|
||||
|
||||
assert isinstance(A(), (int, str))
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class A:
|
||||
pass
|
||||
|
||||
assert issubclass(A, <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y"><caret>int | str</warning>)
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class A:
|
||||
pass
|
||||
|
||||
assert issubclass(A, <caret>(int, str))
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def foo() -> <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y"><caret>int | str</warning>:
|
||||
return 42
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def foo() -> <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y"><caret>int | str | list[dict[int, str]] | set[list[int]] | dict[str, int]</warning>:
|
||||
return 42
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
|
||||
def foo() -> Union[int, str, list[dict[int, str]], set[list[int]], dict[str, int]]:
|
||||
return 42
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
|
||||
def foo() -> Union[int, str]:
|
||||
return 42
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def foo() -> <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y"><caret>int | None | str</warning>:
|
||||
return 42
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
|
||||
def foo() -> <caret>Union[int, None, str]:
|
||||
return 42
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def foo() -> <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y">int<caret> | None</warning>:
|
||||
return 42
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def foo() -> Opt<caret>ional[int]:
|
||||
return 42
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def foo() -> <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y"><caret>int | str | None</warning>:
|
||||
return 42
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
|
||||
def foo() -> <caret>Union[int, str, None]:
|
||||
return 42
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def foo() -> <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y">None | int<caret></warning>:
|
||||
return 42
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def foo() -> Optional[int]<caret>:
|
||||
return 42
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class A:
|
||||
pass
|
||||
|
||||
assert isinstance(A(), <warning descr="Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 do not allow writing union types as X | Y">(int<caret> | str | (list[str] | bool | float)) | dict[str, int]</warning>)
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class A:
|
||||
pass
|
||||
|
||||
assert isinstance(A(), (int<caret>, str, list[str], bool, float, dict[str, int]))
|
||||
Reference in New Issue
Block a user