File: async_.py

package info (click to toggle)
python-jedi 0.19.1%2Bds1-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,680 kB
  • sloc: python: 28,783; makefile: 172; ansic: 13
file content (119 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
"""
Tests for all async use cases.

Currently we're not supporting completion of them, but they should at least not
raise errors or return extremely strange results.
"""

async def x():
    return 1

#? []
x.cr_awai

#? ['cr_await']
x().cr_awai

a = await x()
#? int()
a

async def y():
    argh = await x()
    #? int()
    argh
    #? ['__next__']
    x().__await__().__next
    return 2

class A():
    @staticmethod
    async def b(c=1, d=2):
        return 1

#! 9 ['def b']
await A.b()

#! 11 ['param d=2']
await A.b(d=3)

class Awaitable:
    def __await__(self):
        yield None
        return ''

async def awaitable_test():
    foo = await Awaitable()
    #? str()
    foo

async def asgen():
    yield 1
    await asyncio.sleep(0)
    yield 2

async def wrapper():
    #? int()
    [x async for x in asgen()][0]

    async for y in asgen():
        #? int()
        y

#? ['__anext__']
asgen().__ane
#? []
asgen().mro


# Normal completion (#1092)
normal_var1 = 42

async def foo():
    normal_var2 = False
    #? ['normal_var1', 'normal_var2']
    normal_var


class C:
    @classmethod
    async def async_for_classmethod(cls) -> "C":
        return

    async def async_for_method(cls) -> int:
        return


async def f():
    c = await C.async_for_method()
    #? int()
    c
    d = await C().async_for_method()
    #? int()
    d

    e = await C.async_for_classmethod()
    #? C()
    e
    f = await C().async_for_classmethod()
    #? C()
    f


class AsyncCtxMgr:
    def some_method():
        pass

    async def __aenter__(self):
        return self

    async def __aexit__(self, *args):
        pass


async def asyncctxmgr():
    async with AsyncCtxMgr() as acm:
        #? AsyncCtxMgr()
        acm
        #? ['some_method']
        acm.som