mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
Use the await method properly and just use it instead of some crazy things
This commit is contained in:
@@ -18,7 +18,8 @@ class AsyncBase(BuiltinOverwrite):
|
|||||||
class Coroutine(AsyncBase):
|
class Coroutine(AsyncBase):
|
||||||
special_object_identifier = u'COROUTINE_TYPE'
|
special_object_identifier = u'COROUTINE_TYPE'
|
||||||
|
|
||||||
def execute_await(self):
|
@publish_method('__await__')
|
||||||
|
def _await(self):
|
||||||
return self._func_execution_context.get_return_values()
|
return self._func_execution_context.get_return_values()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -91,16 +91,10 @@ def eval_node(context, element):
|
|||||||
context_set = eval_trailer(context, context_set, trailer)
|
context_set = eval_trailer(context, context_set, trailer)
|
||||||
|
|
||||||
if had_await:
|
if had_await:
|
||||||
await_context_set = ContextSet()
|
await_context_set = context_set.py__getattribute__("__await__")
|
||||||
for context in context_set:
|
if not await_context_set:
|
||||||
try:
|
debug.warning('Tried to run py__await__ on context %s', context)
|
||||||
func = context.execute_await
|
return await_context_set.execute_evaluated()
|
||||||
except AttributeError:
|
|
||||||
debug.warning('Tried to run execute_await on context %s', context)
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
await_context_set |= func()
|
|
||||||
return await_context_set
|
|
||||||
return context_set
|
return context_set
|
||||||
elif typ in ('testlist_star_expr', 'testlist',):
|
elif typ in ('testlist_star_expr', 'testlist',):
|
||||||
# The implicit tuple in statements.
|
# The implicit tuple in statements.
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ async def y():
|
|||||||
argh = await x()
|
argh = await x()
|
||||||
#? int()
|
#? int()
|
||||||
argh
|
argh
|
||||||
|
#? int()
|
||||||
|
x().__await__()
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
async def asgen():
|
async def asgen():
|
||||||
|
|||||||
Reference in New Issue
Block a user