| 1 |
if (foo := 0): |
| 2 |
pass |
| 3 |
|
| 4 |
if (foo := 1): |
| 5 |
pass |
| 6 |
|
| 7 |
if (y := 5 + 5): |
| 8 |
pass |
| 9 |
|
| 10 |
y = (x := 0) |
| 11 |
|
| 12 |
y += (x := 0) |
| 13 |
|
| 14 |
(y := 5 + 5) |
| 15 |
|
| 16 |
test: int = (test2 := 2) |
| 17 |
|
| 18 |
a, b = (test := (1, 2)) |
| 19 |
|
| 20 |
# see also https://github.com/psf/black/issues/2139 |
| 21 |
assert (foo := 42 - 12) |
| 22 |
|
| 23 |
foo(x=(y := f(x))) |
| 24 |
|
| 25 |
|
| 26 |
def foo(answer=(p := 42)): |
| 27 |
... |
| 28 |
|
| 29 |
|
| 30 |
def foo2(answer: (p := 42) = 5): |
| 31 |
... |
| 32 |
|
| 33 |
|
| 34 |
lambda: (x := 1) |
| 35 |
|
| 36 |
a[(x := 12)] |
| 37 |
a[:(x := 13)] |
| 38 |
|
| 39 |
# we don't touch expressions in f-strings but if we do one day, don't break 'em |
| 40 |
f'{(x:=10)}' |
| 41 |
|
| 42 |
|
| 43 |
def a(): |
| 44 |
return (x := 3) |
| 45 |
await (b := 1) |
| 46 |
yield (a := 2) |
| 47 |
raise (c := 3) |
| 48 |
|
| 49 |
def this_is_so_dumb() -> (please := no): |
| 50 |
pass |
| 51 |
|
| 52 |
async def await_the_walrus(): |
| 53 |
with (x := y): |
| 54 |
pass |
| 55 |
|
| 56 |
with (x := y) as z, (a := b) as c: |
| 57 |
pass |
| 58 |
|
| 59 |
with (x := await y): |
| 60 |
pass |
| 61 |
|
| 62 |
with (x := await a, y := await b): |
| 63 |
pass |
| 64 |
|
| 65 |
with ((x := await a, y := await b)): |
| 66 |
pass |
| 67 |
|
| 68 |
with (x := await a), (y := await b): |
| 69 |
pass |
| 70 |
|
| 71 |
|
| 72 |
# output |
| 73 |
if foo := 0: |
| 74 |
pass |
| 75 |
|
| 76 |
if foo := 1: |
| 77 |
pass |
| 78 |
|
| 79 |
if y := 5 + 5: |
| 80 |
pass |
| 81 |
|
| 82 |
y = (x := 0) |
| 83 |
|
| 84 |
y += (x := 0) |
| 85 |
|
| 86 |
(y := 5 + 5) |
| 87 |
|
| 88 |
test: int = (test2 := 2) |
| 89 |
|
| 90 |
a, b = (test := (1, 2)) |
| 91 |
|
| 92 |
# see also https://github.com/psf/black/issues/2139 |
| 93 |
assert (foo := 42 - 12) |
| 94 |
|
| 95 |
foo(x=(y := f(x))) |
| 96 |
|
| 97 |
|
| 98 |
def foo(answer=(p := 42)): ... |
| 99 |
|
| 100 |
|
| 101 |
def foo2(answer: (p := 42) = 5): ... |
| 102 |
|
| 103 |
|
| 104 |
lambda: (x := 1) |
| 105 |
|
| 106 |
a[(x := 12)] |
| 107 |
a[: (x := 13)] |
| 108 |
|
| 109 |
# we don't touch expressions in f-strings but if we do one day, don't break 'em |
| 110 |
f"{(x:=10)}" |
| 111 |
|
| 112 |
|
| 113 |
def a(): |
| 114 |
return (x := 3) |
| 115 |
await (b := 1) |
| 116 |
yield (a := 2) |
| 117 |
raise (c := 3) |
| 118 |
|
| 119 |
|
| 120 |
def this_is_so_dumb() -> (please := no): |
| 121 |
pass |
| 122 |
|
| 123 |
|
| 124 |
async def await_the_walrus(): |
| 125 |
with (x := y): |
| 126 |
pass |
| 127 |
|
| 128 |
with (x := y) as z, (a := b) as c: |
| 129 |
pass |
| 130 |
|
| 131 |
with (x := await y): |
| 132 |
pass |
| 133 |
|
| 134 |
with (x := await a, y := await b): |
| 135 |
pass |
| 136 |
|
| 137 |
with (x := await a, y := await b): |
| 138 |
pass |
| 139 |
|
| 140 |
with (x := await a), (y := await b): |
| 141 |
pass |