Statistics
| Revision:

gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / functional / dangerous_default_value.py @ 745

History | View | Annotate | Download (2.15 KB)

1
# pylint: disable=missing-docstring
2

    
3

    
4
HEHE = {}
5

    
6
def function1(value=[]): # [dangerous-default-value]
7
    """docstring"""
8
    return value
9

    
10
def function2(value=HEHE): # [dangerous-default-value]
11
    """docstring"""
12
    return value
13

    
14
def function3(value):
15
    """docstring"""
16
    return value
17

    
18
def function4(value=set()): # [dangerous-default-value]
19
    """set is mutable and dangerous."""
20
    return value
21

    
22
def function5(value=frozenset()):
23
    """frozenset is immutable and safe."""
24
    return value
25

    
26
GLOBAL_SET = set()
27

    
28
def function6(value=GLOBAL_SET): # [dangerous-default-value]
29
    """set is mutable and dangerous."""
30
    return value
31

    
32
def function7(value=dict()): # [dangerous-default-value]
33
    """dict is mutable and dangerous."""
34
    return value
35

    
36
def function8(value=list()):  # [dangerous-default-value]
37
    """list is mutable and dangerous."""
38
    return value
39

    
40
def function9(value=[1, 2, 3, 4]): # [dangerous-default-value]
41
    """list with items should not output item values in error message"""
42
    return value
43

    
44
def function10(value={'a': 1, 'b': 2}): # [dangerous-default-value]
45
    """dictionaries with items should not output item values in error message"""
46
    return value
47

    
48
def function11(value=list([1, 2, 3])): # [dangerous-default-value]
49
    """list with items should not output item values in error message"""
50
    return value
51

    
52
def function12(value=dict([('a', 1), ('b', 2)])): # [dangerous-default-value]
53
    """dictionaries with items should not output item values in error message"""
54
    return value
55

    
56
OINK = {
57
    'a': 1,
58
    'b': 2
59
}
60

    
61
def function13(value=OINK): # [dangerous-default-value]
62
    """dictionaries with items should not output item values in error message"""
63
    return value
64

    
65
def function14(value=dict([(1, 2), (1, 2, 3)])): # [dangerous-default-value]
66
    """a dictionary which will not be inferred to a syntax AST, but to an
67
    astroid.Instance.
68
    """
69
    return value
70

    
71
INVALID_DICT = dict([(1, 2), (1, 2, 3)])
72

    
73
def function15(value=INVALID_DICT): # [dangerous-default-value]
74
    """The same situation as function14."""
75
    return value
76

    
77
def function16(value={1}): # [dangerous-default-value]
78
    """set literal as default value"""
79
    return value