| 1 |
import asyncio |
| 2 |
|
| 3 |
# Control example |
| 4 |
async def main(): |
| 5 |
await asyncio.sleep(1) |
| 6 |
|
| 7 |
# Remove brackets for short coroutine/task |
| 8 |
async def main(): |
| 9 |
await (asyncio.sleep(1)) |
| 10 |
|
| 11 |
async def main(): |
| 12 |
await ( |
| 13 |
asyncio.sleep(1) |
| 14 |
) |
| 15 |
|
| 16 |
async def main(): |
| 17 |
await (asyncio.sleep(1) |
| 18 |
) |
| 19 |
|
| 20 |
# Check comments |
| 21 |
async def main(): |
| 22 |
await ( # Hello |
| 23 |
asyncio.sleep(1) |
| 24 |
) |
| 25 |
|
| 26 |
async def main(): |
| 27 |
await ( |
| 28 |
asyncio.sleep(1) # Hello |
| 29 |
) |
| 30 |
|
| 31 |
async def main(): |
| 32 |
await ( |
| 33 |
asyncio.sleep(1) |
| 34 |
) # Hello |
| 35 |
|
| 36 |
# Long lines |
| 37 |
async def main(): |
| 38 |
await asyncio.gather(asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1)) |
| 39 |
|
| 40 |
# Same as above but with magic trailing comma in function |
| 41 |
async def main(): |
| 42 |
await asyncio.gather(asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1), asyncio.sleep(1),) |
| 43 |
|
| 44 |
# Cr@zY Br@ck3Tz |
| 45 |
async def main(): |
| 46 |
await ( |
| 47 |
((((((((((((( |
| 48 |
((( ((( |
| 49 |
((( ((( |
| 50 |
((( ((( |
| 51 |
((( ((( |
| 52 |
((black(1))) |
| 53 |
))) ))) |
| 54 |
))) ))) |
| 55 |
))) ))) |
| 56 |
))) ))) |
| 57 |
))))))))))))) |
| 58 |
) |
| 59 |
|
| 60 |
# Keep brackets around non power operations and nested awaits |
| 61 |
async def main(): |
| 62 |
await (set_of_tasks | other_set) |
| 63 |
|
| 64 |
async def main(): |
| 65 |
await (await asyncio.sleep(1)) |
| 66 |
|
| 67 |
# It's awaits all the way down... |
| 68 |
async def main(): |
| 69 |
await (await x) |
| 70 |
|
| 71 |
async def main(): |
| 72 |
await (yield x) |
| 73 |
|
| 74 |
async def main(): |
| 75 |
await (await (asyncio.sleep(1))) |
| 76 |
|
| 77 |
async def main(): |
| 78 |
await (await (await (await (await (asyncio.sleep(1)))))) |
| 79 |
|
| 80 |
async def main(): |
| 81 |
await (yield) |
| 82 |
|
| 83 |
async def main(): |
| 84 |
await (a ** b) |
| 85 |
await (a[b] ** c) |
| 86 |
await (a ** b[c]) |
| 87 |
await ((a + b) ** (c + d)) |
| 88 |
await (a + b) |
| 89 |
await (a[b]) |
| 90 |
await (a[b ** c]) |
| 91 |
|
| 92 |
# output |
| 93 |
import asyncio |
| 94 |
|
| 95 |
|
| 96 |
# Control example |
| 97 |
async def main(): |
| 98 |
await asyncio.sleep(1) |
| 99 |
|
| 100 |
|
| 101 |
# Remove brackets for short coroutine/task |
| 102 |
async def main(): |
| 103 |
await asyncio.sleep(1) |
| 104 |
|
| 105 |
|
| 106 |
async def main(): |
| 107 |
await asyncio.sleep(1) |
| 108 |
|
| 109 |
|
| 110 |
async def main(): |
| 111 |
await asyncio.sleep(1) |
| 112 |
|
| 113 |
|
| 114 |
# Check comments |
| 115 |
async def main(): |
| 116 |
await asyncio.sleep(1) # Hello |
| 117 |
|
| 118 |
|
| 119 |
async def main(): |
| 120 |
await asyncio.sleep(1) # Hello |
| 121 |
|
| 122 |
|
| 123 |
async def main(): |
| 124 |
await asyncio.sleep(1) # Hello |
| 125 |
|
| 126 |
|
| 127 |
# Long lines |
| 128 |
async def main(): |
| 129 |
await asyncio.gather( |
| 130 |
asyncio.sleep(1), |
| 131 |
asyncio.sleep(1), |
| 132 |
asyncio.sleep(1), |
| 133 |
asyncio.sleep(1), |
| 134 |
asyncio.sleep(1), |
| 135 |
asyncio.sleep(1), |
| 136 |
asyncio.sleep(1), |
| 137 |
) |
| 138 |
|
| 139 |
|
| 140 |
# Same as above but with magic trailing comma in function |
| 141 |
async def main(): |
| 142 |
await asyncio.gather( |
| 143 |
asyncio.sleep(1), |
| 144 |
asyncio.sleep(1), |
| 145 |
asyncio.sleep(1), |
| 146 |
asyncio.sleep(1), |
| 147 |
asyncio.sleep(1), |
| 148 |
asyncio.sleep(1), |
| 149 |
asyncio.sleep(1), |
| 150 |
) |
| 151 |
|
| 152 |
|
| 153 |
# Cr@zY Br@ck3Tz |
| 154 |
async def main(): |
| 155 |
await black(1) |
| 156 |
|
| 157 |
|
| 158 |
# Keep brackets around non power operations and nested awaits |
| 159 |
async def main(): |
| 160 |
await (set_of_tasks | other_set) |
| 161 |
|
| 162 |
|
| 163 |
async def main(): |
| 164 |
await (await asyncio.sleep(1)) |
| 165 |
|
| 166 |
|
| 167 |
# It's awaits all the way down... |
| 168 |
async def main(): |
| 169 |
await (await x) |
| 170 |
|
| 171 |
|
| 172 |
async def main(): |
| 173 |
await (yield x) |
| 174 |
|
| 175 |
|
| 176 |
async def main(): |
| 177 |
await (await asyncio.sleep(1)) |
| 178 |
|
| 179 |
|
| 180 |
async def main(): |
| 181 |
await (await (await (await (await asyncio.sleep(1))))) |
| 182 |
|
| 183 |
|
| 184 |
async def main(): |
| 185 |
await (yield) |
| 186 |
|
| 187 |
|
| 188 |
async def main(): |
| 189 |
await (a**b) |
| 190 |
await (a[b] ** c) |
| 191 |
await (a ** b[c]) |
| 192 |
await ((a + b) ** (c + d)) |
| 193 |
await (a + b) |
| 194 |
await a[b] |
| 195 |
await a[b**c] |