File: named_expression.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 (52 lines) | stat: -rw-r--r-- 689 bytes parent folder | download | duplicates (3)
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
# For assignment expressions / named expressions / walrus operators / whatever
# they are called.

# python >= 3.8
b = (a:=1, a)

#? int()
b[0]
#?
b[1]

# Should not fail
b = ('':=1,)

#? int()
b[0]

def test_assignments():
    match = ''
    #? str()
    match
    #? 8 int()
    if match := 1:
        #? int()
        match
    #? int()
    match

def test_assignments2():
    class Foo:
        match = ''
    #? str()
    Foo.match
    #? 13 int()
    if Foo.match := 1:
        #? str()
        Foo.match
    #? str()
    Foo.match

    #?
    y
    #? 16 str()
    if y := Foo.match:
        #? str()
        y
    #? str()
    y

    #? 8 str()
    if z := Foo.match:
        pass