Debian Codegraph @

tests/data/cases/allow_empty_first_line.py

raw
1 def foo():
2 """
3 Docstring
4 """
5
6 # Here we go
7 if x:
8
9 # This is also now fine
10 a = 123
11
12 else:
13 # But not necessary
14 a = 123
15
16 if y:
17
18 while True:
19
20 """
21 Long comment here
22 """
23 a = 123
24
25 if z:
26
27 for _ in range(100):
28 a = 123
29 else:
30
31 try:
32
33 # this should be ok
34 a = 123
35 except:
36
37 """also this"""
38 a = 123
39
40
41 def bar():
42
43 if x:
44 a = 123
45
46
47 def baz():
48
49 # OK
50 if x:
51 a = 123
52
53 def quux():
54
55 new_line = here
56
57
58 class Cls:
59
60 def method(self):
61
62 pass
63
64
65 async def async_fn():
66
67 """Docstring."""
68
69
70 @decorated
71 async def async_fn():
72
73 """Docstring."""
74
75
76 def top_level(
77 a: int,
78 b: str,
79 ) -> Whatever[Generic, Something]:
80
81 def nested(x: int) -> int:
82 pass
83
84 # output
85
86 def foo():
87 """
88 Docstring
89 """
90
91 # Here we go
92 if x:
93
94 # This is also now fine
95 a = 123
96
97 else:
98 # But not necessary
99 a = 123
100
101 if y:
102
103 while True:
104
105 """
106 Long comment here
107 """
108 a = 123
109
110 if z:
111
112 for _ in range(100):
113 a = 123
114 else:
115
116 try:
117
118 # this should be ok
119 a = 123
120 except:
121
122 """also this"""
123 a = 123
124
125
126 def bar():
127
128 if x:
129 a = 123
130
131
132 def baz():
133
134 # OK
135 if x:
136 a = 123
137
138
139 def quux():
140
141 new_line = here
142
143
144 class Cls:
145
146 def method(self):
147
148 pass
149
150
151 async def async_fn():
152 """Docstring."""
153
154
155 @decorated
156 async def async_fn():
157 """Docstring."""
158
159
160 def top_level(
161 a: int,
162 b: str,
163 ) -> Whatever[Generic, Something]:
164
165 def nested(x: int) -> int:
166 pass