File: branches.py

package info (click to toggle)
python-jedi 0.18.0-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 10,556 kB
  • sloc: python: 28,292; makefile: 172; ansic: 13
file content (55 lines) | stat: -rw-r--r-- 903 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
53
54
55
# -----------------
# Simple tests
# -----------------

import random

if random.choice([0, 1]):
    x = ''
else:
    x = 1
if random.choice([0, 1]):
    y = ''
else:
    y = 1

# A simple test
if x != 1:
    x.upper()
else:
    #! 2 attribute-error
    x.upper()
    pass

# This operation is wrong, because the types could be different.
#! 6 type-error-operation
z = x + y
# However, here we have correct types.
if x == y:
    z = x + y
else:
    #! 6 type-error-operation
    z = x + y


# TODO enable this one.
#x = 3
#if x != 1:
#    x.upper()

# -----------------
# With a function
# -----------------

def addition(a, b):
    if type(a) == type(b):
        # Might still be a type error, we might want to change this in the
        # future.
        #! 9 type-error-operation
        return a + b
    else:
        #! 9 type-error-operation
        return a + b

addition(1, 1)
addition(1.0, '')