summaryrefslogtreecommitdiff
path: root/tests/functional/ext/dict_init_mutate.py
blob: f3372bd7e6c169c23a4b20c0998ef82aa0d44bd5 (plain)
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
"""Example cases for dict-init-mutate"""
# pylint: disable=use-dict-literal, invalid-name

base = {}

fruits = {}
for fruit in ["apple", "orange"]:
    fruits[fruit] = 1
    fruits[fruit] += 1

count = 10
fruits = {"apple": 1}
fruits["apple"] += count

config = {}  # [dict-init-mutate]
config['pwd'] = 'hello'

config = {}  # [dict-init-mutate]
config['dir'] = 'bin'
config['user'] = 'me'
config['workers'] = 5
print(config)

config = {}  # Not flagging calls to update for now
config.update({"dir": "bin"})

config = {}  # [dict-init-mutate]
config['options'] = {}  # Identifying nested assignment not supporting this yet.
config['options']['debug'] = False
config['options']['verbose'] = True


config = {}
def update_dict(di):
    """Update a dictionary"""
    di["one"] = 1

update_dict(config)