]> git.madduck.net Git - etc/vim.git/blob - tests/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:

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