blob: 2bbc4e7a222845c8712d0971c1a528007d541423 (
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
39
40
41
42
43
44
45
46
47
48
49
|
# pylint: disable=missing-docstring, invalid-name
MY_DICTIONARY = {"key_one": 1, "key_two": 2, "key_three": 3}
try: # [max-try-statements]
value = MY_DICTIONARY["key_one"]
value += 1
print("This one has an except clause only.")
except KeyError:
pass
try: # [max-try-statements]
value = MY_DICTIONARY["key_one"]
value += 1
print("This one has a finally clause only.")
finally:
pass
try: # [max-try-statements]
value = MY_DICTIONARY["key_one"]
value += 1
print("This one has an except clause...")
print("and also a finally clause!")
except KeyError:
pass
finally:
pass
try: # [max-try-statements]
if "key_one" in MY_DICTIONARY:
entered_if_body = True
print("This verifies that content inside of an if statement is counted too.")
else:
entered_if_body = False
while False:
print("This verifies that content inside of a while loop is counted too.")
for item in []:
print("This verifies that content inside of a for loop is counted too.")
except KeyError:
pass
try:
value = MY_DICTIONARY["key_one"]
except KeyError:
value = 0
|