Debian Codegraph @

tests/data/cases/comments5.py

raw
1 while True:
2 if something.changed:
3 do.stuff() # trailing comment
4 # Comment belongs to the `if` block.
5 # This one belongs to the `while` block.
6
7 # Should this one, too? I guess so.
8
9 # This one is properly standalone now.
10
11 for i in range(100):
12 # first we do this
13 if i % 33 == 0:
14 break
15
16 # then we do this
17 print(i)
18 # and finally we loop around
19
20 with open(some_temp_file) as f:
21 data = f.read()
22
23 try:
24 with open(some_other_file) as w:
25 w.write(data)
26
27 except OSError:
28 print("problems")
29
30 import sys
31
32
33 # leading function comment
34 def wat():
35 ...
36 # trailing function comment
37
38
39 # SECTION COMMENT
40
41
42 # leading 1
43 @deco1
44 # leading 2
45 @deco2(with_args=True)
46 # leading 3
47 @deco3
48 def decorated1(): ...
49
50
51 # leading 1
52 @deco1
53 # leading 2
54 @deco2(with_args=True)
55 # leading function comment
56 def decorated1(): ...
57
58
59 some_instruction
60
61
62 # This comment should be split from `some_instruction` by two lines.
63 def g(): ...
64
65
66 if __name__ == "__main__":
67 main()