]> 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:

Omit extra space in kwarg unpacking if it's an argument
[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             return NO
109
110         if prevp.type == token.EQUAL:
111             if prevp.parent and prevp.parent.type in {
112                 syms.typedargslist,
113                 syms.varargslist,
114                 syms.parameters,
115                 syms.arglist,
116                 syms.argument,
117             }:
118                 return NO
119
120         elif prevp.type == token.DOUBLESTAR:
121             if prevp.parent and prevp.parent.type in {
122                 syms.typedargslist,
123                 syms.varargslist,
124                 syms.parameters,
125                 syms.arglist,
126                 syms.dictsetmaker,
127             }:
128                 return NO
129
130
131 ###############################################################################
132 # SECTION BECAUSE SECTIONS
133 ###############################################################################
134
135
136 def g():
137     NO = ''
138     SPACE = ' '
139     DOUBLESPACE = '  '
140
141     t = leaf.type
142     p = leaf.parent
143     v = leaf.value
144
145     # Comment because comments
146
147     if t in ALWAYS_NO_SPACE:
148         pass
149     if t == token.COMMENT:
150         return DOUBLESPACE
151
152     # Another comment because more comments
153     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
154
155     prev = leaf.prev_sibling
156     if not prev:
157         prevp = preceding_leaf(p)
158
159         if not prevp or prevp.type in OPENING_BRACKETS:
160             # Start of the line or a bracketed expression.
161             # More than one line for the comment.
162             return NO
163
164         if prevp.type == token.EQUAL:
165             if prevp.parent and prevp.parent.type in {
166                 syms.typedargslist,
167                 syms.varargslist,
168                 syms.parameters,
169                 syms.arglist,
170                 syms.argument,
171             }:
172                 return NO