]> git.madduck.net Git - etc/vim.git/blob - tests/data/empty_lines.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Add code snippet for using black badge in .rst (#356)
[etc/vim.git] / tests / data / empty_lines.py
1 """Docstring."""
2
3
4 # leading comment
5 def f():
6     NO = ''
7     SPACE = ' '
8     DOUBLESPACE = '  '
9
10     t = leaf.type
11     p = leaf.parent  # trailing comment
12     v = leaf.value
13
14     if t in ALWAYS_NO_SPACE:
15         pass
16     if t == token.COMMENT:  # another trailing comment
17         return DOUBLESPACE
18
19
20     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
21
22
23     prev = leaf.prev_sibling
24     if not prev:
25         prevp = preceding_leaf(p)
26         if not prevp or prevp.type in OPENING_BRACKETS:
27
28
29             return NO
30
31
32         if prevp.type == token.EQUAL:
33             if prevp.parent and prevp.parent.type in {
34                 syms.typedargslist,
35                 syms.varargslist,
36                 syms.parameters,
37                 syms.arglist,
38                 syms.argument,
39             }:
40                 return NO
41
42         elif prevp.type == token.DOUBLESTAR:
43             if prevp.parent and prevp.parent.type in {
44                 syms.typedargslist,
45                 syms.varargslist,
46                 syms.parameters,
47                 syms.arglist,
48                 syms.dictsetmaker,
49             }:
50                 return NO
51
52 ###############################################################################
53 # SECTION BECAUSE SECTIONS
54 ###############################################################################
55
56 def g():
57     NO = ''
58     SPACE = ' '
59     DOUBLESPACE = '  '
60
61     t = leaf.type
62     p = leaf.parent
63     v = leaf.value
64
65     # Comment because comments
66
67     if t in ALWAYS_NO_SPACE:
68         pass
69     if t == token.COMMENT:
70         return DOUBLESPACE
71
72     # Another comment because more comments
73     assert p is not None, f'INTERNAL ERROR: hand-made leaf without parent: {leaf!r}'
74
75     prev = leaf.prev_sibling
76     if not prev:
77         prevp = preceding_leaf(p)
78
79         if not prevp or prevp.type in OPENING_BRACKETS:
80             # Start of the line or a bracketed expression.
81             # More than one line for the comment.
82             return NO
83
84         if prevp.type == token.EQUAL:
85             if prevp.parent and prevp.parent.type in {
86                 syms.typedargslist,
87                 syms.varargslist,
88                 syms.parameters,
89                 syms.arglist,
90                 syms.argument,
91             }:
92                 return NO
93
94
95 # output
96
97
98 """Docstring."""
99
100
101 # leading comment
102 def f():
103     NO = ""
104     SPACE = " "
105     DOUBLESPACE = "  "
106
107     t = leaf.type
108     p = leaf.parent  # trailing comment
109     v = leaf.value
110
111     if t in ALWAYS_NO_SPACE:
112         pass
113     if t == token.COMMENT:  # another trailing comment
114         return DOUBLESPACE
115
116     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
117
118     prev = leaf.prev_sibling
119     if not prev:
120         prevp = preceding_leaf(p)
121         if not prevp or prevp.type in OPENING_BRACKETS:
122
123             return NO
124
125         if prevp.type == token.EQUAL:
126             if prevp.parent and prevp.parent.type in {
127                 syms.typedargslist,
128                 syms.varargslist,
129                 syms.parameters,
130                 syms.arglist,
131                 syms.argument,
132             }:
133                 return NO
134
135         elif prevp.type == token.DOUBLESTAR:
136             if prevp.parent and prevp.parent.type in {
137                 syms.typedargslist,
138                 syms.varargslist,
139                 syms.parameters,
140                 syms.arglist,
141                 syms.dictsetmaker,
142             }:
143                 return NO
144
145
146 ###############################################################################
147 # SECTION BECAUSE SECTIONS
148 ###############################################################################
149
150
151 def g():
152     NO = ""
153     SPACE = " "
154     DOUBLESPACE = "  "
155
156     t = leaf.type
157     p = leaf.parent
158     v = leaf.value
159
160     # Comment because comments
161
162     if t in ALWAYS_NO_SPACE:
163         pass
164     if t == token.COMMENT:
165         return DOUBLESPACE
166
167     # Another comment because more comments
168     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
169
170     prev = leaf.prev_sibling
171     if not prev:
172         prevp = preceding_leaf(p)
173
174         if not prevp or prevp.type in OPENING_BRACKETS:
175             # Start of the line or a bracketed expression.
176             # More than one line for the comment.
177             return NO
178
179         if prevp.type == token.EQUAL:
180             if prevp.parent and prevp.parent.type in {
181                 syms.typedargslist,
182                 syms.varargslist,
183                 syms.parameters,
184                 syms.arglist,
185                 syms.argument,
186             }:
187                 return NO