PY-55548 Use actual return type for "Specify return type using annotation"

For async functions, unwrap return type from Awaitable or Coroutine


Merge-request: IJ-MR-146295
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

(cherry picked from commit 9fe8d02a9d8bb584b9d6972ce999912bd93875e6)

IJ-MR-146295

GitOrigin-RevId: 9bad4877a069268a2d0181cac70b9a0d399cb5e6
This commit is contained in:
Aleksandr.Govenko
2024-10-28 15:41:56 +00:00
committed by intellij-monorepo-bot
parent 3bf01bc0c5
commit d5f9bf8de0
24 changed files with 91 additions and 25 deletions

View File

@@ -1,2 +1,2 @@
def foo(x: object, y: object) -> object:
def foo(x: object, y: object) -> None:
pass

View File

@@ -1,4 +1,4 @@
def foo(x: object, y: object) -> object:
def foo(x: object, y: object) -> None:
pass

View File

@@ -1,2 +1,2 @@
def foo(x: object, y: object) -> object:
def foo(x: object, y: object) -> None:
pass

View File

@@ -1,2 +1,2 @@
def foo(**x: object<caret>) -> object:
def foo(**x: object<caret>) -> None:
pass

View File

@@ -1,2 +1,2 @@
def foo(x: bool<caret>, y: bool) -> object:
def foo(x: bool<caret>, y: bool) -> str:
return "42"

View File

@@ -1,2 +1,2 @@
def foo(*x: object<caret>, **y: object) -> object:
def foo(*x: object<caret>, **y: object) -> None:
pass

View File

@@ -3,7 +3,7 @@ class MyClass:
pass
def method(self, x):
# type: (object) -> object
# type: (object) -> None
pass

View File

@@ -1,3 +1,3 @@
def foo(x, y):
# type: (object, object) -> object
# type: (object, object) -> None
pass

View File

@@ -0,0 +1,5 @@
async def bar() -> int:
return 42
def fo<caret>o(x, y):
return bar()

View File

@@ -0,0 +1,8 @@
from typing import Any, Coroutine
async def bar() -> int:
return 42
def foo(x, y) -> Coroutine[Any, Any, int]:
return bar()

View File

@@ -1,2 +1,2 @@
def foo(x, y) -> object:
def foo(x, y) -> None:
pass

View File

@@ -1,4 +1,4 @@
def foo(x, y) -> object:
def foo(x, y) -> None:
pass

View File

@@ -1,2 +1,2 @@
def foo(x, y) -> object:
def foo(x, y) -> None:
pass

View File

@@ -0,0 +1,2 @@
async def fo<caret>o(x, y):
return 42

View File

@@ -0,0 +1,2 @@
async def foo(x, y) -> int:
return 42

View File

@@ -1,4 +1,4 @@
def my_func(p1=1) -> object:
def my_func(p1=1) -> int:
return p1
d = my_func(1)

View File

@@ -1,4 +1,4 @@
def my_func(p1=1) -> object:
def my_func(p1=1) -> int:
return p1
d = my_func(1)

View File

@@ -1,4 +1,4 @@
def foo() -> object:
def foo() -> None:
@decorator
def bar():
pass

View File

@@ -1,4 +1,4 @@
def foo() -> object:
def foo() -> None:
@decorator
def bar():
pass

View File

@@ -1,4 +1,7 @@
def g(x) -> object:
from typing import Any
def g(x) -> Any:
return x