X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/e911c79809c4fd9b0773dea5b6a0e710b59614cf..6243540ae739e323c936769f6f4ace0272707405:/tests/empty_lines.py?ds=sidebyside diff --git a/tests/empty_lines.py b/tests/empty_lines.py index fe86b38..5b7ce92 100644 --- a/tests/empty_lines.py +++ b/tests/empty_lines.py @@ -1,3 +1,7 @@ +"""Docstring.""" + + +# leading comment def f(): NO = '' SPACE = ' ' @@ -12,15 +16,19 @@ def f(): if t == token.COMMENT: # another trailing comment return DOUBLESPACE + assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}" + prev = leaf.prev_sibling if not prev: prevp = preceding_leaf(p) if not prevp or prevp.type in OPENING_BRACKETS: + return NO + if prevp.type == token.EQUAL: if prevp.parent and prevp.parent.type in { syms.typedargslist, @@ -41,12 +49,10 @@ def f(): }: return NO - ############################################################################### # SECTION BECAUSE SECTIONS ############################################################################### - def g(): NO = '' SPACE = ' ' @@ -64,7 +70,7 @@ def g(): return DOUBLESPACE # Another comment because more comments - assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}" + assert p is not None, f'INTERNAL ERROR: hand-made leaf without parent: {leaf!r}' prev = leaf.prev_sibling if not prev: @@ -89,10 +95,14 @@ def g(): # output +"""Docstring.""" + + +# leading comment def f(): - NO = '' - SPACE = ' ' - DOUBLESPACE = ' ' + NO = "" + SPACE = " " + DOUBLESPACE = " " t = leaf.type p = leaf.parent # trailing comment @@ -109,42 +119,52 @@ def f(): if not prev: prevp = preceding_leaf(p) if not prevp or prevp.type in OPENING_BRACKETS: + return NO if prevp.type == token.EQUAL: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.argument, - }: + if ( + prevp.parent + and prevp.parent.type in { + syms.typedargslist, + syms.varargslist, + syms.parameters, + syms.arglist, + syms.argument, + } + ): return NO elif prevp.type == token.DOUBLESTAR: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.dictsetmaker, - }: + if ( + prevp.parent + and prevp.parent.type in { + syms.typedargslist, + syms.varargslist, + syms.parameters, + syms.arglist, + syms.dictsetmaker, + } + ): return NO ############################################################################### # SECTION BECAUSE SECTIONS ############################################################################### + + def g(): - NO = '' - SPACE = ' ' - DOUBLESPACE = ' ' + NO = "" + SPACE = " " + DOUBLESPACE = " " t = leaf.type p = leaf.parent v = leaf.value # Comment because comments + if t in ALWAYS_NO_SPACE: pass if t == token.COMMENT: @@ -163,11 +183,14 @@ def g(): return NO if prevp.type == token.EQUAL: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.argument, - }: + if ( + prevp.parent + and prevp.parent.type in { + syms.typedargslist, + syms.varargslist, + syms.parameters, + syms.arglist, + syms.argument, + } + ): return NO