aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2021-12-25 22:31:14 -0600
committerBill Wendling <isanbard@gmail.com>2021-12-25 23:09:56 -0600
commit5b75e6fd8791e97a61ae658f8126353f6fee9ae7 (patch)
treec8200391fee64abf0ffed1f46f74c34a19fa29e7
parent46180bc4f9f803b319f6dcc9748c74d5a743d8f2 (diff)
downloadyapf-5b75e6fd8791e97a61ae658f8126353f6fee9ae7.tar.gz
Use "logical line" instead of "unwrapped line"
The concept of an "unwrapped line" is better described as a "logical line". Use that nomenclature instead.
-rw-r--r--CHANGELOG2
-rw-r--r--README.rst16
-rw-r--r--yapf/yapflib/format_decision_state.py31
-rw-r--r--yapf/yapflib/format_token.py10
-rw-r--r--yapf/yapflib/line_joiner.py8
-rw-r--r--yapf/yapflib/logical_line.py (renamed from yapf/yapflib/unwrapped_line.py)46
-rw-r--r--yapf/yapflib/pytree_unwrapper.py76
-rw-r--r--yapf/yapflib/reformatter.py225
-rw-r--r--yapf/yapflib/style.py2
-rw-r--r--yapf/yapflib/yapf_api.py28
-rw-r--r--yapftests/blank_line_calculator_test.py40
-rw-r--r--yapftests/format_decision_state_test.py24
-rw-r--r--yapftests/line_joiner_test.py6
-rw-r--r--yapftests/logical_line_test.py (renamed from yapftests/unwrapped_line_test.py)48
-rw-r--r--yapftests/pytree_unwrapper_test.py104
-rw-r--r--yapftests/reformatter_basic_test.py692
-rw-r--r--yapftests/reformatter_buganizer_test.py524
-rw-r--r--yapftests/reformatter_facebook_test.py80
-rw-r--r--yapftests/reformatter_pep8_test.py172
-rw-r--r--yapftests/reformatter_python3_test.py100
-rw-r--r--yapftests/reformatter_style_config_test.py24
-rw-r--r--yapftests/reformatter_verify_test.py22
-rw-r--r--yapftests/subtype_assigner_test.py42
-rw-r--r--yapftests/yapf_test_helper.py12
24 files changed, 1163 insertions, 1171 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 13e03a7..ba56ac2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,8 @@
- Use GitHub Actions instead of Travis for CI.
- Clean up the FormatToken interface to limit how much it relies upon the
pytree node object.
+- Rename "unwrapped_line" module to "logical_line."
+- Rename "UnwrappedLine" class to "LogicalLine."
### Fixed
- Enable `BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF` knob for "pep8" style, so
method definitions inside a class are surrounded by a single blank line as
diff --git a/README.rst b/README.rst
index 739acbd..12286a9 100644
--- a/README.rst
+++ b/README.rst
@@ -843,7 +843,7 @@ Knobs
The penalty for characters over the column limit.
``SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT``
- The penalty incurred by adding a line split to the unwrapped line. The more
+ The penalty incurred by adding a line split to the logical line. The more
line splits added the higher the penalty.
``SPLIT_PENALTY_IMPORT_NAMES``
@@ -962,15 +962,15 @@ Gory Details
Algorithm Design
----------------
-The main data structure in YAPF is the ``UnwrappedLine`` object. It holds a list
-of ``FormatToken``\s, that we would want to place on a single line if there were
-no column limit. An exception being a comment in the middle of an expression
-statement will force the line to be formatted on more than one line. The
-formatter works on one ``UnwrappedLine`` object at a time.
+The main data structure in YAPF is the ``LogicalLine`` object. It holds a list
+of ``FormatToken``\s, that we would want to place on a single line if there
+were no column limit. An exception being a comment in the middle of an
+expression statement will force the line to be formatted on more than one line.
+The formatter works on one ``LogicalLine`` object at a time.
-An ``UnwrappedLine`` typically won't affect the formatting of lines before or
+An ``LogicalLine`` typically won't affect the formatting of lines before or
after it. There is a part of the algorithm that may join two or more
-``UnwrappedLine``\s into one line. For instance, an if-then statement with a
+``LogicalLine``\s into one line. For instance, an if-then statement with a
short body can be placed on a single line:
.. code-block:: python
diff --git a/yapf/yapflib/format_decision_state.py b/yapf/yapflib/format_decision_state.py
index be5770c..74d0861 100644
--- a/yapf/yapflib/format_decision_state.py
+++ b/yapf/yapflib/format_decision_state.py
@@ -27,22 +27,22 @@ through the code to commit the whitespace formatting.
"""
from yapf.yapflib import format_token
+from yapf.yapflib import logical_line
from yapf.yapflib import object_state
from yapf.yapflib import split_penalty
from yapf.yapflib import style
from yapf.yapflib import subtypes
-from yapf.yapflib import unwrapped_line
class FormatDecisionState(object):
- """The current state when indenting an unwrapped line.
+ """The current state when indenting a logical line.
The FormatDecisionState object is meant to be copied instead of referenced.
Attributes:
first_indent: The indent of the first token.
column: The number of used columns in the current line.
- line: The unwrapped line we're currently processing.
+ line: The logical line we're currently processing.
next_token: The next token to be formatted.
paren_level: The level of nesting inside (), [], and {}.
lowest_level_on_line: The lowest paren_level on the current line.
@@ -64,7 +64,7 @@ class FormatDecisionState(object):
'first_indent'.
Arguments:
- line: (UnwrappedLine) The unwrapped line we're currently processing.
+ line: (LogicalLine) The logical line we're currently processing.
first_indent: (int) The indent of the first token.
"""
self.next_token = line.first
@@ -234,7 +234,7 @@ class FormatDecisionState(object):
return False
if (not _IsLastScopeInLine(bracket) or
- unwrapped_line.IsSurroundedByBrackets(bracket)):
+ logical_line.IsSurroundedByBrackets(bracket)):
last_token = bracket.matching_bracket
else:
last_token = _LastTokenInLine(bracket.matching_bracket)
@@ -268,7 +268,7 @@ class FormatDecisionState(object):
return False
if (previous.value == '(' and not previous.is_pseudo and
- not unwrapped_line.IsSurroundedByBrackets(previous)):
+ not logical_line.IsSurroundedByBrackets(previous)):
pptoken = previous.previous_token
if (pptoken and not pptoken.is_name and not pptoken.is_keyword and
SurroundedByParens(current)):
@@ -300,7 +300,7 @@ class FormatDecisionState(object):
tok = tok.next_token
func_call_or_string_format = tok and tok.value == '%'
if func_call_or_string_format:
- open_bracket = unwrapped_line.IsSurroundedByBrackets(current)
+ open_bracket = logical_line.IsSurroundedByBrackets(current)
if open_bracket:
if open_bracket.value in '[{':
if not self._FitsOnLine(open_bracket,
@@ -314,7 +314,7 @@ class FormatDecisionState(object):
subtypes.DICTIONARY_KEY not in current.next_token.subtypes):
# If we have a list of tuples, then we can get a similar look as above. If
# the full list cannot fit on the line, then we want a split.
- open_bracket = unwrapped_line.IsSurroundedByBrackets(current)
+ open_bracket = logical_line.IsSurroundedByBrackets(current)
if (open_bracket and open_bracket.value in '[{' and
subtypes.SUBSCRIPT_BRACKET not in open_bracket.subtypes):
if not self._FitsOnLine(current, current.matching_bracket):
@@ -382,7 +382,7 @@ class FormatDecisionState(object):
# b=1,
# c=2)
if (self._FitsOnLine(previous, previous.matching_bracket) and
- unwrapped_line.IsSurroundedByBrackets(previous)):
+ logical_line.IsSurroundedByBrackets(previous)):
# An argument to a function is a function call with named
# assigns.
return False
@@ -551,7 +551,7 @@ class FormatDecisionState(object):
if (current.is_comment and
previous.lineno < current.lineno - current.value.count('\n')):
- # If a comment comes in the middle of an unwrapped line (like an if
+ # If a comment comes in the middle of a logical line (like an if
# conditional with comments interspersed), then we want to split if the
# original comments were on a separate line.
return True
@@ -1088,14 +1088,7 @@ class FormatDecisionState(object):
return False
def _ContainerFitsOnStartLine(self, opening):
- """Check if the container can fit on its starting line.
-
- Arguments:
- opening: (FormatToken) The unwrapped line we're currently processing.
-
- Returns:
- True if the container fits on the start line.
- """
+ """Check if the container can fit on its starting line."""
return (opening.matching_bracket.total_length - opening.total_length +
self.stack[-1].indent) <= self.column_limit
@@ -1128,7 +1121,7 @@ def _IsFunctionCallWithArguments(token):
def _IsArgumentToFunction(token):
- bracket = unwrapped_line.IsSurroundedByBrackets(token)
+ bracket = logical_line.IsSurroundedByBrackets(token)
if not bracket or bracket.value != '(':
return False
previous = bracket.previous_token
diff --git a/yapf/yapflib/format_token.py b/yapf/yapflib/format_token.py
index 42eeaa5..487f3a9 100644
--- a/yapf/yapflib/format_token.py
+++ b/yapf/yapflib/format_token.py
@@ -55,10 +55,10 @@ class FormatToken(object):
Attributes:
node: The PyTree node this token represents.
- next_token: The token in the unwrapped line after this token or None if this
- is the last token in the unwrapped line.
- previous_token: The token in the unwrapped line before this token or None if
- this is the first token in the unwrapped line.
+ next_token: The token in the logical line after this token or None if this
+ is the last token in the logical line.
+ previous_token: The token in the logical line before this token or None if
+ this is the first token in the logical line.
matching_bracket: If a bracket token ('[', '{', or '(') the matching
bracket.
parameters: If this and its following tokens make up a parameter list, then
@@ -74,7 +74,7 @@ class FormatToken(object):
formatter won't place n spaces before all comments. Only those that are
moved to the end of a line of code. The formatter may use different
spacing when appropriate.
- total_length: The total length of the unwrapped line up to and including
+ total_length: The total length of the logical line up to and including
whitespace and this token. However, this doesn't include the initial
indentation amount.
split_penalty: The penalty for splitting the line before this token.
diff --git a/yapf/yapflib/line_joiner.py b/yapf/yapflib/line_joiner.py
index 84346c2..f0acd2f 100644
--- a/yapf/yapflib/line_joiner.py
+++ b/yapf/yapflib/line_joiner.py
@@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Join unwrapped lines together.
+"""Join logical lines together.
Determine how many lines can be joined into one line. For instance, we could
join these statements into one line:
@@ -43,8 +43,8 @@ def CanMergeMultipleLines(lines, last_was_merged=False):
"""Determine if multiple lines can be joined into one.
Arguments:
- lines: (list of UnwrappedLine) This is a splice of UnwrappedLines from the
- full code base.
+ lines: (list of LogicalLine) This is a splice of LogicalLines from the full
+ code base.
last_was_merged: (bool) The last line was merged.
Returns:
@@ -91,7 +91,7 @@ def _CanMergeLineIntoIfStatement(lines, limit):
'continue', and 'break'.
Arguments:
- lines: (list of UnwrappedLine) The lines we are wanting to merge.
+ lines: (list of LogicalLine) The lines we are wanting to merge.
limit: (int) The amount of space remaining on the line.
Returns:
diff --git a/yapf/yapflib/unwrapped_line.py b/yapf/yapflib/logical_line.py
index 3b480a0..5723440 100644
--- a/yapf/yapflib/unwrapped_line.py
+++ b/yapf/yapflib/logical_line.py
@@ -11,12 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-"""UnwrappedLine primitive for formatting.
+"""LogicalLine primitive for formatting.
-An unwrapped line is the containing data structure produced by the parser. It
-collects all nodes (stored in FormatToken objects) that could appear on a
-single line if there were no line length restrictions. It's then used by the
-parser to perform the wrapping required to comply with the style guide.
+A logical line is the containing data structure produced by the parser. It
+collects all nodes (stored in FormatToken objects) that could appear on a single
+line if there were no line length restrictions. It's then used by the parser to
+perform the wrapping required to comply with the style guide.
"""
from yapf.yapflib import format_token
@@ -29,8 +29,8 @@ from yapf.yapflib import subtypes
from lib2to3.fixer_util import syms as python_symbols
-class UnwrappedLine(object):
- """Represents a single unwrapped line in the output.
+class LogicalLine(object):
+ """Represents a single logical line in the output.
Attributes:
depth: indentation depth of this line. This is just a numeric value used to
@@ -41,7 +41,7 @@ class UnwrappedLine(object):
def __init__(self, depth, tokens=None):
"""Constructor.
- Creates a new unwrapped line with the given depth an initial list of tokens.
+ Creates a new logical line with the given depth an initial list of tokens.
Constructs the doubly-linked lists for format tokens using their built-in
next_token and previous_token attributes.
@@ -63,7 +63,7 @@ class UnwrappedLine(object):
def CalculateFormattingInformation(self):
"""Calculate the split penalty and total length for the tokens."""
# Say that the first token in the line should have a space before it. This
- # means only that if this unwrapped line is joined with a predecessor line,
+ # means only that if this logical line is joined with a predecessor line,
# then there will be a space between them.
self.first.spaces_required_before = 1
self.first.total_length = len(self.first.value)
@@ -106,23 +106,23 @@ class UnwrappedLine(object):
if not self.has_semicolon or self.disable:
return [self]
- uwlines = []
- uwline = UnwrappedLine(self.depth)
+ llines = []
+ lline = LogicalLine(self.depth)
for tok in self._tokens:
if tok.value == ';':
- uwlines.append(uwline)
- uwline = UnwrappedLine(self.depth)
+ llines.append(lline)
+ lline = LogicalLine(self.depth)
else:
- uwline.AppendToken(tok)
+ lline.AppendToken(tok)
- if uwline.tokens:
- uwlines.append(uwline)
+ if lline.tokens:
+ llines.append(lline)
- for uwline in uwlines:
- uwline.first.previous_token = None
- uwline.last.next_token = None
+ for lline in llines:
+ lline.first.previous_token = None
+ lline.last.next_token = None
- return uwlines
+ return llines
############################################################################
# Token Access and Manipulation Methods #
@@ -184,7 +184,7 @@ class UnwrappedLine(object):
def __repr__(self): # pragma: no cover
tokens_repr = ','.join(
'{0}({1!r})'.format(tok.name, tok.value) for tok in self._tokens)
- return 'UnwrappedLine(depth={0}, tokens=[{1}])'.format(
+ return 'LogicalLine(depth={0}, tokens=[{1}])'.format(
self.depth, tokens_repr)
############################################################################
@@ -204,10 +204,10 @@ class UnwrappedLine(object):
@property
def lineno(self):
- """Return the line number of this unwrapped line.
+ """Return the line number of this logical line.
Returns:
- The line number of the first token in this unwrapped line.
+ The line number of the first token in this logical line.
"""
return self.first.lineno
diff --git a/yapf/yapflib/pytree_unwrapper.py b/yapf/yapflib/pytree_unwrapper.py
index 15d9dd7..1b05b0e 100644
--- a/yapf/yapflib/pytree_unwrapper.py
+++ b/yapf/yapflib/pytree_unwrapper.py
@@ -11,13 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-"""PyTreeUnwrapper - produces a list of unwrapped lines from a pytree.
+"""PyTreeUnwrapper - produces a list of logical lines from a pytree.
-[for a description of what an unwrapped line is, see unwrapped_line.py]
+[for a description of what a logical line is, see logical_line.py]
This is a pytree visitor that goes over a parse tree and produces a list of
-UnwrappedLine containers from it, each with its own depth and containing all
-the tokens that could fit on the line if there were no maximal line-length
+LogicalLine containers from it, each with its own depth and containing all the
+tokens that could fit on the line if there were no maximal line-length
limitations.
Note: a precondition to running this visitor and obtaining correct results is
@@ -32,29 +32,29 @@ from lib2to3 import pytree
from lib2to3.pgen2 import token as grammar_token
from yapf.yapflib import format_token
+from yapf.yapflib import logical_line
from yapf.yapflib import object_state
from yapf.yapflib import pytree_utils
from yapf.yapflib import pytree_visitor
from yapf.yapflib import split_penalty
from yapf.yapflib import style
from yapf.yapflib import subtypes
-from yapf.yapflib import unwrapped_line
def UnwrapPyTree(tree):
- """Create and return a list of unwrapped lines from the given pytree.
+ """Create and return a list of logical lines from the given pytree.
Arguments:
- tree: the top-level pytree node to unwrap.
+ tree: the top-level pytree node to unwrap..
Returns:
- A list of UnwrappedLine objects.
+ A list of LogicalLine objects.
"""
unwrapper = PyTreeUnwrapper()
unwrapper.Visit(tree)
- uwlines = unwrapper.GetUnwrappedLines()
- uwlines.sort(key=lambda x: x.lineno)
- return uwlines
+ llines = unwrapper.GetLogicalLines()
+ llines.sort(key=lambda x: x.lineno)
+ return llines
# Grammar tokens considered as whitespace for the purpose of unwrapping.
@@ -80,40 +80,40 @@ class PyTreeUnwrapper(pytree_visitor.PyTreeVisitor):
"""
def __init__(self):
- # A list of all unwrapped lines finished visiting so far.
- self._unwrapped_lines = []
+ # A list of all logical lines finished visiting so far.
+ self._logical_lines = []
- # Builds up a "current" unwrapped line while visiting pytree nodes. Some
- # nodes will finish a line and start a new one.
- self._cur_unwrapped_line = unwrapped_line.UnwrappedLine(0)
+ # Builds up a "current" logical line while visiting pytree nodes. Some nodes
+ # will finish a line and start a new one.
+ self._cur_logical_line = logical_line.LogicalLine(0)
# Current indentation depth.
self._cur_depth = 0
- def GetUnwrappedLines(self):
+ def GetLogicalLines(self):
"""Fetch the result of the tree walk.
Note: only call this after visiting the whole tree.
Returns:
- A list of UnwrappedLine objects.
+ A list of LogicalLine objects.
"""
# Make sure the last line that was being populated is flushed.
self._StartNewLine()
- return self._unwrapped_lines
+ return self._logical_lines
def _StartNewLine(self):
"""Finish current line and start a new one.
- Place the currently accumulated line into the _unwrapped_lines list and
+ Place the currently accumulated line into the _logical_lines list and
start a new one.
"""
- if self._cur_unwrapped_line.tokens:
- self._unwrapped_lines.append(self._cur_unwrapped_line)
- _MatchBrackets(self._cur_unwrapped_line)
- _IdentifyParameterLists(self._cur_unwrapped_line)
- _AdjustSplitPenalty(self._cur_unwrapped_line)
- self._cur_unwrapped_line = unwrapped_line.UnwrappedLine(self._cur_depth)
+ if self._cur_logical_line.tokens:
+ self._logical_lines.append(self._cur_logical_line)
+ _MatchBrackets(self._cur_logical_line)
+ _IdentifyParameterLists(self._cur_logical_line)
+ _AdjustSplitPenalty(self._cur_logical_line)
+ self._cur_logical_line = logical_line.LogicalLine(self._cur_depth)
_STMT_TYPES = frozenset({
'if_stmt',
@@ -152,7 +152,7 @@ class PyTreeUnwrapper(pytree_visitor.PyTreeVisitor):
"""Helper for visiting compound statements.
Python compound statements serve as containers for other statements. Thus,
- when we encounter a new compound statement we start a new unwrapped line.
+ when we encounter a new compound statement, we start a new logical line.
Arguments:
node: the node to visit.
@@ -285,7 +285,7 @@ class PyTreeUnwrapper(pytree_visitor.PyTreeVisitor):
def DefaultLeafVisit(self, leaf):
"""Default visitor for tree leaves.
- A tree leaf is always just gets appended to the current unwrapped line.
+ A tree leaf is always just gets appended to the current logical line.
Arguments:
leaf: the leaf to visit.
@@ -294,13 +294,13 @@ class PyTreeUnwrapper(pytree_visitor.PyTreeVisitor):
self._StartNewLine()
elif leaf.type != grammar_token.COMMENT or leaf.value.strip():
# Add non-whitespace tokens and comments that aren't empty.
- self._cur_unwrapped_line.AppendNode(leaf)
+ self._cur_logical_line.AppendNode(leaf)
_BRACKET_MATCH = {')': '(', '}': '{', ']': '['}
-def _MatchBrackets(uwline):
+def _MatchBrackets(line):
"""Visit the node and match the brackets.
For every open bracket ('[', '{', or '('), find the associated closing bracket
@@ -308,10 +308,10 @@ def _MatchBrackets(uwline):
or close bracket.
Arguments:
- uwline: (UnwrappedLine) An unwrapped line.
+ line: (LogicalLine) A logical line.
"""
bracket_stack = []
- for token in uwline.tokens:
+ for token in line.tokens:
if token.value in pytree_utils.OPENING_BRACKETS:
bracket_stack.append(token)
elif token.value in pytree_utils.CLOSING_BRACKETS:
@@ -325,18 +325,18 @@ def _MatchBrackets(uwline):
token.container_opening = bracket
-def _IdentifyParameterLists(uwline):
+def _IdentifyParameterLists(line):
"""Visit the node to create a state for parameter lists.
For instance, a parameter is considered an "object" with its first and last
token uniquely identifying the object.
Arguments:
- uwline: (UnwrappedLine) An unwrapped line.
+ line: (LogicalLine) A logical line.
"""
func_stack = []
param_stack = []
- for tok in uwline.tokens:
+ for tok in line.tokens:
# Identify parameter list objects.
if subtypes.FUNC_DEF in tok.subtypes:
assert tok.next_token.value == '('
@@ -358,17 +358,17 @@ def _IdentifyParameterLists(uwline):
func_stack[-1].parameters.append(object_state.Parameter(start, tok))
-def _AdjustSplitPenalty(uwline):
+def _AdjustSplitPenalty(line):
"""Visit the node and adjust the split penalties if needed.
A token shouldn't be split if it's not within a bracket pair. Mark any token
that's not within a bracket pair as "unbreakable".
Arguments:
- uwline: (UnwrappedLine) An unwrapped line.
+ line: (LogicalLine) An logical line.
"""
bracket_level = 0
- for index, token in enumerate(uwline.tokens):
+ for index, token in enumerate(line.tokens):
if index and not bracket_level:
pytree_utils.SetNodeAnnotation(token.node,
pytree_utils.Annotation.SPLIT_PENALTY,
diff --git a/yapf/yapflib/reformatter.py b/yapf/yapflib/reformatter.py
index a61d463..7242894 100644
--- a/yapf/yapflib/reformatter.py
+++ b/yapf/yapflib/reformatter.py
@@ -13,9 +13,8 @@
# limitations under the License.
"""Decide what the format for the code should be.
-The `unwrapped_line.UnwrappedLine`s are now ready to be formatted.
-UnwrappedLines that can be merged together are. The best formatting is returned
-as a string.
+The `logical_line.LogicalLine`s are now ready to be formatted. LogicalLInes that
+can be merged together are. The best formatting is returned as a string.
Reformat(): the main function exported by this module.
"""
@@ -36,11 +35,11 @@ from yapf.yapflib import style
from yapf.yapflib import verifier
-def Reformat(uwlines, verify=False, lines=None):
- """Reformat the unwrapped lines.
+def Reformat(llines, verify=False, lines=None):
+ """Reformat the logical lines.
Arguments:
- uwlines: (list of unwrapped_line.UnwrappedLine) Lines we want to format.
+ llines: (list of logical_line.LogicalLine) Lines we want to format.
verify: (bool) True if reformatted code should be verified for syntax.
lines: (set of int) The lines which can be modified or None if there is no
line range restriction.
@@ -49,81 +48,81 @@ def Reformat(uwlines, verify=False, lines=None):
A string representing the reformatted code.
"""
final_lines = []
- prev_uwline = None # The previous line.
+ prev_line = None # The previous line.
indent_width = style.Get('INDENT_WIDTH')
- for uwline in _SingleOrMergedLines(uwlines):
- first_token = uwline.first
- _FormatFirstToken(first_token, uwline.depth, prev_uwline, final_lines)
+ for lline in _SingleOrMergedLines(llines):
+ first_token = lline.first
+ _FormatFirstToken(first_token, lline.depth, prev_line, final_lines)
- indent_amt = indent_width * uwline.depth
- state = format_decision_state.FormatDecisionState(uwline, indent_amt)
+ indent_amt = indent_width * lline.depth
+ state = format_decision_state.FormatDecisionState(lline, indent_amt)
state.MoveStateToNextToken()
- if not uwline.disable:
- if uwline.first.is_comment:
- uwline.first.node.value = uwline.first.node.value.rstrip()
- elif uwline.last.is_comment:
- uwline.last.node.value = uwline.last.node.value.rstrip()
- if prev_uwline and prev_uwline.disable:
+ if not lline.disable:
+ if lline.first.is_comment:
+ lline.first.node.value = lline.first.node.value.rstrip()
+ elif lline.last.is_comment:
+ lline.last.node.value = lline.last.node.value.rstrip()
+ if prev_line and prev_line.disable:
# Keep the vertical spacing between a disabled and enabled formatting
# region.
- _RetainRequiredVerticalSpacingBetweenTokens(uwline.first,
- prev_uwline.last, lines)
- if any(tok.is_comment for tok in uwline.tokens):
- _RetainVerticalSpacingBeforeComments(uwline)
-
- if uwline.disable or _LineHasContinuationMarkers(uwline):
- _RetainHorizontalSpacing(uwline)
- _RetainRequiredVerticalSpacing(uwline, prev_uwline, lines)
+ _RetainRequiredVerticalSpacingBetweenTokens(lline.first,
+ prev_line.last, lines)
+ if any(tok.is_comment for tok in lline.tokens):
+ _RetainVerticalSpacingBeforeComments(lline)
+
+ if lline.disable or _LineHasContinuationMarkers(lline):
+ _RetainHorizontalSpacing(lline)
+ _RetainRequiredVerticalSpacing(lline, prev_line, lines)
_EmitLineUnformatted(state)
- elif (_LineContainsPylintDisableLineTooLong(uwline) or
- _LineContainsI18n(uwline)):
+ elif (_LineContainsPylintDisableLineTooLong(lline) or
+ _LineContainsI18n(lline)):
# Don't modify vertical spacing, but fix any horizontal spacing issues.
- _RetainRequiredVerticalSpacing(uwline, prev_uwline, lines)
+ _RetainRequiredVerticalSpacing(lline, prev_line, lines)
_EmitLineUnformatted(state)
- elif _CanPlaceOnSingleLine(uwline) and not any(tok.must_break_before
- for tok in uwline.tokens):
- # The unwrapped line fits on one line.
+ elif _CanPlaceOnSingleLine(lline) and not any(tok.must_break_before
+ for tok in lline.tokens):
+ # The logical line fits on one line.
while state.next_token:
state.AddTokenToState(newline=False, dry_run=False)
elif not _AnalyzeSolutionSpace(state):
# Failsafe mode. If there isn't a solution to the line, then just emit
# it as is.
- state = format_decision_state.FormatDecisionState(uwline, indent_amt)
+ state = format_decision_state.FormatDecisionState(lline, indent_amt)
state.MoveStateToNextToken()
- _RetainHorizontalSpacing(uwline)
- _RetainRequiredVerticalSpacing(uwline, prev_uwline, None)
+ _RetainHorizontalSpacing(lline)
+ _RetainRequiredVerticalSpacing(lline, prev_line, None)
_EmitLineUnformatted(state)
- final_lines.append(uwline)
- prev_uwline = uwline
+ final_lines.append(lline)
+ prev_line = lline
_AlignTrailingComments(final_lines)
return _FormatFinalLines(final_lines, verify)
-def _RetainHorizontalSpacing(uwline):
+def _RetainHorizontalSpacing(line):
"""Retain all horizontal spacing between tokens."""
- for tok in uwline.tokens:
- tok.RetainHorizontalSpacing(uwline.first.column, uwline.depth)
+ for tok in line.tokens:
+ tok.RetainHorizontalSpacing(line.first.column, line.depth)
-def _RetainRequiredVerticalSpacing(cur_uwline, prev_uwline, lines):
+def _RetainRequiredVerticalSpacing(cur_line, prev_line, lines):
"""Retain all vertical spacing between lines."""
prev_tok = None
- if prev_uwline is not None:
- prev_tok = prev_uwline.last
+ if prev_line is not None:
+ prev_tok = prev_line.last
- if cur_uwline.disable:
+ if cur_line.disable:
# After the first token we are acting on a single line. So if it is
# disabled we must not reformat.
lines = set()
- for cur_tok in cur_uwline.tokens:
+ for cur_tok in cur_line.tokens:
_RetainRequiredVerticalSpacingBetweenTokens(cur_tok, prev_tok, lines)
prev_tok = cur_tok
@@ -165,10 +164,10 @@ def _RetainRequiredVerticalSpacingBetweenTokens(cur_tok, prev_tok, lines):
cur_tok.AdjustNewlinesBefore(required_newlines)
-def _RetainVerticalSpacingBeforeComments(uwline):
+def _RetainVerticalSpacingBeforeComments(line):
"""Retain vertical spacing before comments."""
prev_token = None
- for tok in uwline.tokens:
+ for tok in line.tokens:
if tok.is_comment and prev_token:
if tok.lineno - tok.value.count('\n') - prev_token.lineno > 1:
tok.AdjustNewlinesBefore(ONE_BLANK_LINE)
@@ -203,57 +202,57 @@ def _EmitLineUnformatted(state):
state.AddTokenToState(newline=newline, dry_run=False)
-def _LineContainsI18n(uwline):
+def _LineContainsI18n(line):
"""Return true if there are i18n comments or function calls in the line.
I18n comments and pseudo-function calls are closely related. They cannot
be moved apart without breaking i18n.
Arguments:
- uwline: (unwrapped_line.UnwrappedLine) The line currently being formatted.
+ line: (logical_line.LogicalLine) The line currently being formatted.
Returns:
True if the line contains i18n comments or function calls. False otherwise.
"""
if style.Get('I18N_COMMENT'):
- for tok in uwline.tokens:
+ for tok in line.tokens:
if tok.is_comment and re.match(style.Get('I18N_COMMENT'), tok.value):
# Contains an i18n comment.
return True
if style.Get('I18N_FUNCTION_CALL'):
- length = len(uwline.tokens)
+ length = len(line.tokens)
for index in range(length - 1):
- if (uwline.tokens[index + 1].value == '(' and
- uwline.tokens[index].value in style.Get('I18N_FUNCTION_CALL')):
+ if (line.tokens[index + 1].value == '(' and
+ line.tokens[index].value in style.Get('I18N_FUNCTION_CALL')):
return True
return False
-def _LineContainsPylintDisableLineTooLong(uwline):
+def _LineContainsPylintDisableLineTooLong(line):
"""Return true if there is a "pylint: disable=line-too-long" comment."""
- return re.search(r'\bpylint:\s+disable=line-too-long\b', uwline.last.value)
+ return re.search(r'\bpylint:\s+disable=line-too-long\b', line.last.value)
-def _LineHasContinuationMarkers(uwline):
+def _LineHasContinuationMarkers(line):
"""Return true if the line has continuation markers in it."""
- return any(tok.is_continuation for tok in uwline.tokens)
+ return any(tok.is_continuation for tok in line.tokens)
-def _CanPlaceOnSingleLine(uwline):
- """Determine if the unwrapped line can go on a single line.
+def _CanPlaceOnSingleLine(line):
+ """Determine if the logical line can go on a single line.
Arguments:
- uwline: (unwrapped_line.UnwrappedLine) The line currently being formatted.
+ line: (logical_line.LogicalLine) The line currently being formatted.
Returns:
True if the line can or should be added to a single line. False otherwise.
"""
- token_names = [x.name for x in uwline.tokens]
+ token_names = [x.name for x in line.tokens]
if (style.Get('FORCE_MULTILINE_DICT') and 'LBRACE' in token_names):
return False
- indent_amt = style.Get('INDENT_WIDTH') * uwline.depth
- last = uwline.last
+ indent_amt = style.Get('INDENT_WIDTH') * line.depth
+ last = line.last
last_index = -1
if (last.is_pylint_comment or last.is_pytype_comment or
last.is_copybara_comment):
@@ -262,7 +261,7 @@ def _CanPlaceOnSingleLine(uwline):
if last is None:
return True
return (last.total_length + indent_amt <= style.Get('COLUMN_LIMIT') and
- not any(tok.is_comment for tok in uwline.tokens[:last_index]))
+ not any(tok.is_comment for tok in line.tokens[:last_index]))
def _AlignTrailingComments(final_lines):
@@ -305,7 +304,7 @@ def _AlignTrailingComments(final_lines):
all_pc_line_lengths.append([])
continue
- # Calculate the length of each line in this unwrapped line.
+ # Calculate the length of each line in this logical line.
line_content = ''
pc_line_lengths = []
@@ -561,20 +560,19 @@ def _ReconstructPath(initial_state, current):
NESTED_DEPTH = []
-def _FormatFirstToken(first_token, indent_depth, prev_uwline, final_lines):
- """Format the first token in the unwrapped line.
+def _FormatFirstToken(first_token, indent_depth, prev_line, final_lines):
+ """Format the first token in the logical line.
- Add a newline and the required indent before the first token of the unwrapped
+ Add a newline and the required indent before the first token of the logical
line.
Arguments:
- first_token: (format_token.FormatToken) The first token in the unwrapped
- line.
+ first_token: (format_token.FormatToken) The first token in the logical line.
indent_depth: (int) The line's indentation depth.
- prev_uwline: (list of unwrapped_line.UnwrappedLine) The unwrapped line
- previous to this line.
- final_lines: (list of unwrapped_line.UnwrappedLine) The unwrapped lines
- that have already been processed.
+ prev_line: (list of logical_line.LogicalLine) The logical line previous to
+ this line.
+ final_lines: (list of logical_line.LogicalLine) The logical lines that have
+ already been processed.
"""
global NESTED_DEPTH
while NESTED_DEPTH and NESTED_DEPTH[-1] > indent_depth:
@@ -589,7 +587,7 @@ def _FormatFirstToken(first_token, indent_depth, prev_uwline, final_lines):
NESTED_DEPTH.append(indent_depth)
first_token.AddWhitespacePrefix(
- _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
+ _CalculateNumberOfNewlines(first_token, indent_depth, prev_line,
final_lines, first_nested),
indent_level=indent_depth)
@@ -606,18 +604,18 @@ def _IsClassOrDef(tok):
tok.next_token.value == 'def')
-def _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
+def _CalculateNumberOfNewlines(first_token, indent_depth, prev_line,
final_lines, first_nested):
"""Calculate the number of newlines we need to add.
Arguments:
- first_token: (format_token.FormatToken) The first token in the unwrapped
+ first_token: (format_token.FormatToken) The first token in the logical
line.
indent_depth: (int) The line's indentation depth.
- prev_uwline: (list of unwrapped_line.UnwrappedLine) The unwrapped line
- previous to this line.
- final_lines: (list of unwrapped_line.UnwrappedLine) The unwrapped lines
- that have already been processed.
+ prev_line: (list of logical_line.LogicalLine) The logical line previous to
+ this line.
+ final_lines: (list of logical_line.LogicalLine) The logical lines that have
+ already been processed.
first_nested: (boolean) Whether this is the first nested class or function.
Returns:
@@ -625,7 +623,7 @@ def _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
"""
# TODO(morbo): Special handling for imports.
# TODO(morbo): Create a knob that can tune these.
- if prev_uwline is None:
+ if prev_line is None:
# The first line in the file. Don't add blank lines.
# FIXME(morbo): Is this correct?
if first_token.newlines is not None:
@@ -633,11 +631,11 @@ def _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
return 0
if first_token.is_docstring:
- if (prev_uwline.first.value == 'class' and
+ if (prev_line.first.value == 'class' and
style.Get('BLANK_LINE_BEFORE_CLASS_DOCSTRING')):
# Enforce a blank line before a class's docstring.
return ONE_BLANK_LINE
- elif (prev_uwline.first.value.startswith('#') and
+ elif (prev_line.first.value.startswith('#') and
style.Get('BLANK_LINE_BEFORE_MODULE_DOCSTRING')):
# Enforce a blank line before a module's docstring.
return ONE_BLANK_LINE
@@ -645,13 +643,13 @@ def _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
return NO_BLANK_LINES
if first_token.is_name and not indent_depth:
- if prev_uwline.first.value in {'from', 'import'}:
+ if prev_line.first.value in {'from', 'import'}:
# Support custom number of blank lines between top-level imports and
# variable definitions.
return 1 + style.Get(
'BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES')
- prev_last_token = prev_uwline.last
+ prev_last_token = prev_line.last
if prev_last_token.is_docstring:
if (not indent_depth and first_token.value in {'class', 'def', 'async'}):
# Separate a class or function from the module-level docstring with
@@ -674,7 +672,7 @@ def _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
if not indent_depth:
# This is a top-level class or function.
is_inline_comment = prev_last_token.whitespace_prefix.count('\n') == 0
- if (not prev_uwline.disable and prev_last_token.is_comment and
+ if (not prev_line.disable and prev_last_token.is_comment and
not is_inline_comment):
# This token follows a non-inline comment.
if _NoBlankLinesBeforeCurrentToken(prev_last_token.value, first_token,
@@ -694,7 +692,7 @@ def _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
if first_token.newlines is not None:
first_token.newlines = None
return NO_BLANK_LINES
- elif _IsClassOrDef(prev_uwline.first):
+ elif _IsClassOrDef(prev_line.first):
if first_nested and not style.Get(
'BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF'):
first_token.newlines = None
@@ -717,11 +715,11 @@ def _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
return NO_BLANK_LINES
-def _SingleOrMergedLines(uwlines):
+def _SingleOrMergedLines(lines):
"""Generate the lines we want to format.
Arguments:
- uwlines: (list of unwrapped_line.UnwrappedLine) Lines we want to format.
+ lines: (list of logical_line.LogicalLine) Lines we want to format.
Yields:
Either a single line, if the current line cannot be merged with the
@@ -729,38 +727,38 @@ def _SingleOrMergedLines(uwlines):
"""
index = 0
last_was_merged = False
- while index < len(uwlines):
- if uwlines[index].disable:
- uwline = uwlines[index]
+ while index < len(lines):
+ if lines[index].disable:
+ line = lines[index]
index += 1
- while index < len(uwlines):
- column = uwline.last.column + 2
- if uwlines[index].lineno != uwline.lineno:
+ while index < len(lines):
+ column = line.last.column + 2
+ if lines[index].lineno != line.lineno:
break
- if uwline.last.value != ':':
+ if line.last.value != ':':
leaf = pytree.Leaf(
- type=token.SEMI, value=';', context=('', (uwline.lineno, column)))
- uwline.AppendToken(format_token.FormatToken(leaf))
- for tok in uwlines[index].tokens:
- uwline.AppendToken(tok)
+ type=token.SEMI, value=';', context=('', (line.lineno, column)))
+ line.AppendToken(format_token.FormatToken(leaf))
+ for tok in lines[index].tokens:
+ line.AppendToken(tok)
index += 1
- yield uwline
- elif line_joiner.CanMergeMultipleLines(uwlines[index:], last_was_merged):
+ yield line
+ elif line_joiner.CanMergeMultipleLines(lines[index:], last_was_merged):
# TODO(morbo): This splice is potentially very slow. Come up with a more
# performance-friendly way of determining if two lines can be merged.
- next_uwline = uwlines[index + 1]
- for tok in next_uwline.tokens:
- uwlines[index].AppendToken(tok)
- if (len(next_uwline.tokens) == 1 and
- next_uwline.first.is_multiline_string):
+ next_line = lines[index + 1]
+ for tok in next_line.tokens:
+ lines[index].AppendToken(tok)
+ if (len(next_line.tokens) == 1 and
+ next_line.first.is_multiline_string):
# This may be a multiline shebang. In that case, we want to retain the
# formatting. Otherwise, it could mess up the shell script's syntax.
- uwlines[index].disable = True
- yield uwlines[index]
+ lines[index].disable = True
+ yield lines[index]
index += 2
last_was_merged = True
else:
- yield uwlines[index]
+ yield lines[index]
index += 1
last_was_merged = False
@@ -777,9 +775,8 @@ def _NoBlankLinesBeforeCurrentToken(text, cur_token, prev_token):
Arguments:
text: (unicode) The text of the docstring or comment before the current
token.
- cur_token: (format_token.FormatToken) The current token in the unwrapped
- line.
- prev_token: (format_token.FormatToken) The previous token in the unwrapped
+ cur_token: (format_token.FormatToken) The current token in the logical line.
+ prev_token: (format_token.FormatToken) The previous token in the logical
line.
Returns:
diff --git a/yapf/yapflib/style.py b/yapf/yapflib/style.py
index 40b23c4..233a64e 100644
--- a/yapf/yapflib/style.py
+++ b/yapf/yapflib/style.py
@@ -392,7 +392,7 @@ _STYLE_HELP = dict(
SPLIT_PENALTY_EXCESS_CHARACTER=textwrap.dedent("""\
The penalty for characters over the column limit."""),
SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT=textwrap.dedent("""\
- The penalty incurred by adding a line split to the unwrapped line. The
+ The penalty incurred by adding a line split to the logical line. The
more line splits added the higher the penalty."""),
SPLIT_PENALTY_IMPORT_NAMES=textwrap.dedent("""\
The penalty of splitting a list of "import as" names. For example:
diff --git a/yapf/yapflib/yapf_api.py b/yapf/yapflib/yapf_api.py
index 06c9a73..09c31bc 100644
--- a/yapf/yapflib/yapf_api.py
+++ b/yapf/yapflib/yapf_api.py
@@ -142,13 +142,13 @@ def FormatTree(tree, style_config=None, lines=None, verify=False):
split_penalty.ComputeSplitPenalties(tree)
blank_line_calculator.CalculateBlankLines(tree)
- uwlines = pytree_unwrapper.UnwrapPyTree(tree)
- for uwl in uwlines:
- uwl.CalculateFormattingInformation()
+ llines = pytree_unwrapper.UnwrapPyTree(tree)
+ for lline in llines:
+ lline.CalculateFormattingInformation()
lines = _LineRangesToSet(lines)
- _MarkLinesToFormat(uwlines, lines)
- return reformatter.Reformat(_SplitSemicolons(uwlines), verify, lines)
+ _MarkLinesToFormat(llines, lines)
+ return reformatter.Reformat(_SplitSemicolons(llines), verify, lines)
def FormatCode(unformatted_source,
@@ -252,10 +252,10 @@ def ReadFile(filename, logger=None):
raise
-def _SplitSemicolons(uwlines):
+def _SplitSemicolons(lines):
res = []
- for uwline in uwlines:
- res.extend(uwline.Split())
+ for line in lines:
+ res.extend(line.Split())
return res
@@ -276,23 +276,23 @@ def _LineRangesToSet(line_ranges):
return line_set
-def _MarkLinesToFormat(uwlines, lines):
+def _MarkLinesToFormat(llines, lines):
"""Skip sections of code that we shouldn't reformat."""
if lines:
- for uwline in uwlines:
+ for uwline in llines:
uwline.disable = not lines.intersection(
range(uwline.lineno, uwline.last.lineno + 1))
# Now go through the lines and disable any lines explicitly marked as
# disabled.
index = 0
- while index < len(uwlines):
- uwline = uwlines[index]
+ while index < len(llines):
+ uwline = llines[index]
if uwline.is_comment:
if _DisableYAPF(uwline.first.value.strip()):
index += 1
- while index < len(uwlines):
- uwline = uwlines[index]
+ while index < len(llines):
+ uwline = llines[index]
line = uwline.first.value.strip()
if uwline.is_comment and _EnableYAPF(line):
if not _DisableYAPF(line):
diff --git a/yapftests/blank_line_calculator_test.py b/yapftests/blank_line_calculator_test.py
index 80dc55c..18fa83e 100644
--- a/yapftests/blank_line_calculator_test.py
+++ b/yapftests/blank_line_calculator_test.py
@@ -41,8 +41,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
def foo():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testComplexDecorators(self):
unformatted_code = textwrap.dedent("""\
@@ -77,8 +77,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
def method(self):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testCodeAfterFunctionsAndClasses(self):
unformatted_code = textwrap.dedent("""\
@@ -122,8 +122,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
except Error as error:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testCommentSpacing(self):
unformatted_code = textwrap.dedent("""\
@@ -188,8 +188,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
# comment
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testCommentBeforeMethod(self):
code = textwrap.dedent("""\
@@ -199,8 +199,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
def f(self):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testCommentsBeforeClassDefs(self):
code = textwrap.dedent('''\
@@ -212,8 +212,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
class Foo(object):
pass
''')
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testCommentsBeforeDecorator(self):
code = textwrap.dedent("""\
@@ -222,8 +222,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
def a():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
code = textwrap.dedent("""\
# Hello world
@@ -233,8 +233,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
def a():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testCommentsAfterDecorator(self):
code = textwrap.dedent("""\
@@ -250,8 +250,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
def test_unicode_filename_in_sdist(self, sdist_unicode, tmpdir, monkeypatch):
pass
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testInnerClasses(self):
unformatted_code = textwrap.dedent("""\
@@ -274,8 +274,8 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
class DeployAPIHTTPError(Error):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testLinesOnRangeBoundary(self):
unformatted_code = textwrap.dedent(u"""\
diff --git a/yapftests/format_decision_state_test.py b/yapftests/format_decision_state_test.py
index 39e7e8e..9d62267 100644
--- a/yapftests/format_decision_state_test.py
+++ b/yapftests/format_decision_state_test.py
@@ -17,9 +17,9 @@ import textwrap
import unittest
from yapf.yapflib import format_decision_state
+from yapf.yapflib import logical_line
from yapf.yapflib import pytree_utils
from yapf.yapflib import style
-from yapf.yapflib import unwrapped_line
from yapftests import yapf_test_helper
@@ -35,12 +35,12 @@ class FormatDecisionStateTest(yapf_test_helper.YAPFTest):
def f(a, b):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- uwline = unwrapped_line.UnwrappedLine(0, _FilterLine(uwlines[0]))
- uwline.CalculateFormattingInformation()
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ lline = logical_line.LogicalLine(0, _FilterLine(llines[0]))
+ lline.CalculateFormattingInformation()
# Add: 'f'
- state = format_decision_state.FormatDecisionState(uwline, 0)
+ state = format_decision_state.FormatDecisionState(lline, 0)
state.MoveStateToNextToken()
self.assertEqual('f', state.next_token.value)
self.assertFalse(state.CanSplit(False))
@@ -89,12 +89,12 @@ class FormatDecisionStateTest(yapf_test_helper.YAPFTest):
def f(a, b):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- uwline = unwrapped_line.UnwrappedLine(0, _FilterLine(uwlines[0]))
- uwline.CalculateFormattingInformation()
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ lline = logical_line.LogicalLine(0, _FilterLine(llines[0]))
+ lline.CalculateFormattingInformation()
# Add: 'f'
- state = format_decision_state.FormatDecisionState(uwline, 0)
+ state = format_decision_state.FormatDecisionState(lline, 0)
state.MoveStateToNextToken()
self.assertEqual('f', state.next_token.value)
self.assertFalse(state.CanSplit(False))
@@ -133,10 +133,10 @@ class FormatDecisionStateTest(yapf_test_helper.YAPFTest):
self.assertEqual(repr(state), repr(clone))
-def _FilterLine(uwline):
- """Filter out nonsemantic tokens from the UnwrappedLines."""
+def _FilterLine(lline):
+ """Filter out nonsemantic tokens from the LogicalLines."""
return [
- ft for ft in uwline.tokens
+ ft for ft in lline.tokens
if ft.name not in pytree_utils.NONSEMANTIC_TOKENS
]
diff --git a/yapftests/line_joiner_test.py b/yapftests/line_joiner_test.py
index 67252a2..2eaf164 100644
--- a/yapftests/line_joiner_test.py
+++ b/yapftests/line_joiner_test.py
@@ -29,14 +29,14 @@ class LineJoinerTest(yapf_test_helper.YAPFTest):
style.SetGlobalStyle(style.CreatePEP8Style())
def _CheckLineJoining(self, code, join_lines):
- """Check that the given UnwrappedLines are joined as expected.
+ """Check that the given LogicalLines are joined as expected.
Arguments:
code: The code to check to see if we can join it.
join_lines: True if we expect the lines to be joined.
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(line_joiner.CanMergeMultipleLines(uwlines), join_lines)
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(line_joiner.CanMergeMultipleLines(llines), join_lines)
def testSimpleSingleLineStatement(self):
code = textwrap.dedent(u"""\
diff --git a/yapftests/unwrapped_line_test.py b/yapftests/logical_line_test.py
index 90be1a1..6876efe 100644
--- a/yapftests/unwrapped_line_test.py
+++ b/yapftests/logical_line_test.py
@@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Tests for yapf.unwrapped_line."""
+"""Tests for yapf.logical_line."""
import textwrap
import unittest
@@ -20,62 +20,62 @@ from lib2to3 import pytree
from lib2to3.pgen2 import token
from yapf.yapflib import format_token
+from yapf.yapflib import logical_line
from yapf.yapflib import split_penalty
-from yapf.yapflib import unwrapped_line
from yapftests import yapf_test_helper
-class UnwrappedLineBasicTest(unittest.TestCase):
+class LogicalLineBasicTest(unittest.TestCase):
def testConstruction(self):
toks = _MakeFormatTokenList([(token.DOT, '.'), (token.VBAR, '|')])
- uwl = unwrapped_line.UnwrappedLine(20, toks)
- self.assertEqual(20, uwl.depth)
- self.assertEqual(['DOT', 'VBAR'], [tok.name for tok in uwl.tokens])
+ lline = logical_line.LogicalLine(20, toks)
+ self.assertEqual(20, lline.depth)
+ self.assertEqual(['DOT', 'VBAR'], [tok.name for tok in lline.tokens])
def testFirstLast(self):
toks = _MakeFormatTokenList([(token.DOT, '.'), (token.LPAR, '('),
(token.VBAR, '|')])
- uwl = unwrapped_line.UnwrappedLine(20, toks)
- self.assertEqual(20, uwl.depth)
- self.assertEqual('DOT', uwl.first.name)
- self.assertEqual('VBAR', uwl.last.name)
+ lline = logical_line.LogicalLine(20, toks)
+ self.assertEqual(20, lline.depth)
+ self.assertEqual('DOT', lline.first.name)
+ self.assertEqual('VBAR', lline.last.name)
def testAsCode(self):
toks = _MakeFormatTokenList([(token.DOT, '.'), (token.LPAR, '('),
(token.VBAR, '|')])
- uwl = unwrapped_line.UnwrappedLine(2, toks)
- self.assertEqual(' . ( |', uwl.AsCode())
+ lline = logical_line.LogicalLine(2, toks)
+ self.assertEqual(' . ( |', lline.AsCode())
def testAppendToken(self):
- uwl = unwrapped_line.UnwrappedLine(0)
- uwl.AppendToken(_MakeFormatTokenLeaf(token.LPAR, '('))
- uwl.AppendToken(_MakeFormatTokenLeaf(token.RPAR, ')'))
- self.assertEqual(['LPAR', 'RPAR'], [tok.name for tok in uwl.tokens])
+ lline = logical_line.LogicalLine(0)
+ lline.AppendToken(_MakeFormatTokenLeaf(token.LPAR, '('))
+ lline.AppendToken(_MakeFormatTokenLeaf(token.RPAR, ')'))
+ self.assertEqual(['LPAR', 'RPAR'], [tok.name for tok in lline.tokens])
def testAppendNode(self):
- uwl = unwrapped_line.UnwrappedLine(0)
- uwl.AppendNode(pytree.Leaf(token.LPAR, '('))
- uwl.AppendNode(pytree.Leaf(token.RPAR, ')'))
- self.assertEqual(['LPAR', 'RPAR'], [tok.name for tok in uwl.tokens])
+ lline = logical_line.LogicalLine(0)
+ lline.AppendNode(pytree.Leaf(token.LPAR, '('))
+ lline.AppendNode(pytree.Leaf(token.RPAR, ')'))
+ self.assertEqual(['LPAR', 'RPAR'], [tok.name for tok in lline.tokens])
-class UnwrappedLineFormattingInformationTest(yapf_test_helper.YAPFTest):
+class LogicalLineFormattingInformationTest(yapf_test_helper.YAPFTest):
def testFuncDef(self):
code = textwrap.dedent(r"""
def f(a, b):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
+ llines = yapf_test_helper.ParseAndUnwrap(code)
- f = uwlines[0].tokens[1]
+ f = llines[0].tokens[1]
self.assertFalse(f.can_break_before)
self.assertFalse(f.must_break_before)
self.assertEqual(f.split_penalty, split_penalty.UNBREAKABLE)
- lparen = uwlines[0].tokens[2]
+ lparen = llines[0].tokens[2]
self.assertFalse(lparen.can_break_before)
self.assertFalse(lparen.must_break_before)
self.assertEqual(lparen.split_penalty, split_penalty.UNBREAKABLE)
diff --git a/yapftests/pytree_unwrapper_test.py b/yapftests/pytree_unwrapper_test.py
index f95f366..b6ab809 100644
--- a/yapftests/pytree_unwrapper_test.py
+++ b/yapftests/pytree_unwrapper_test.py
@@ -23,22 +23,22 @@ from yapftests import yapf_test_helper
class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
- def _CheckUnwrappedLines(self, uwlines, list_of_expected):
- """Check that the given UnwrappedLines match expectations.
+ def _CheckLogicalLines(self, llines, list_of_expected):
+ """Check that the given LogicalLines match expectations.
Args:
- uwlines: list of UnwrappedLine
+ llines: list of LogicalLine
list_of_expected: list of (depth, values) pairs. Non-semantic tokens are
filtered out from the expected values.
"""
actual = []
- for uwl in uwlines:
+ for lline in llines:
filtered_values = [
ft.value
- for ft in uwl.tokens
+ for ft in lline.tokens
if ft.name not in pytree_utils.NONSEMANTIC_TOKENS
]
- actual.append((uwl.depth, filtered_values))
+ actual.append((lline.depth, filtered_values))
self.assertEqual(list_of_expected, actual)
@@ -48,8 +48,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
# a comment
y = 2
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['x', '=', '1']),
(0, ['# a comment']),
(0, ['y', '=', '2']),
@@ -60,8 +60,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
y = (1 +
x)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['y', '=', '(', '1', '+', 'x', ')']),
])
@@ -70,8 +70,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
x = 1 # a comment
y = 2
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['x', '=', '1', '# a comment']),
(0, ['y', '=', '2']),
])
@@ -82,8 +82,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
x = 1
y = 2
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['if', 'foo', ':']),
(1, ['x', '=', '1']),
(1, ['y', '=', '2']),
@@ -96,8 +96,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
x = 1
y = 2
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['# c1']),
(0, ['if', 'foo', ':', '# c2']),
(1, ['x', '=', '1']),
@@ -112,8 +112,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
# c3
y = 2
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['if', 'foo', ':']),
(1, ['# c1']),
(1, ['x', '=', '1', '# c2']),
@@ -131,8 +131,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
# c3
z = 1
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['if', 'x', ':']),
(1, ['x', '=', '1', '# c1']),
(0, ['elif', 'y', ':', '# c2']),
@@ -151,8 +151,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
j = 1
k = 1
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['if', 'x', ':']),
(1, ['x', '=', '1', '# c1']),
(1, ['while', 't', ':']),
@@ -167,8 +167,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
# c2
x = 1
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['while', 'x', '>', '1', ':', '# c1']),
(1, ['# c2']),
(1, ['x', '=', '1']),
@@ -187,8 +187,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
finally:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['try', ':']),
(1, ['pass']),
(0, ['except', ':']),
@@ -207,8 +207,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
# c2
return x
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['def', 'foo', '(', 'x', ')', ':', '# c1']),
(1, ['# c2']),
(1, ['return', 'x']),
@@ -224,8 +224,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
# c4
return x
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['def', 'foo', '(', 'x', ')', ':', '# c1']),
(1, ['# c2']),
(1, ['return', 'x']),
@@ -240,8 +240,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
# c2
p = 1
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['class', 'Klass', ':', '# c1']),
(1, ['# c2']),
(1, ['p', '=', '1']),
@@ -251,8 +251,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
code = textwrap.dedent(r"""
def f(): return 37
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['def', 'f', '(', ')', ':']),
(1, ['return', '37']),
])
@@ -265,8 +265,8 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
def f():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [
(0, ['# Comment #1']),
(0, ['# Comment #2']),
(0, ['def', 'f', '(', ')', ':']),
@@ -281,48 +281,48 @@ class PytreeUnwrapperTest(yapf_test_helper.YAPFTest):
'c', # hello world
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckUnwrappedLines(uwlines, [(0, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckLogicalLines(llines, [(0, [
'a', '=', '[', "'a'", ',', "'b'", ',', "'c'", ',', '# hello world', ']'
])])
class MatchBracketsTest(yapf_test_helper.YAPFTest):
- def _CheckMatchingBrackets(self, uwlines, list_of_expected):
+ def _CheckMatchingBrackets(self, llines, list_of_expected):
"""Check that the tokens have the expected matching bracket.
Arguments:
- uwlines: list of UnwrappedLine.
+ llines: list of LogicalLine.
list_of_expected: list of (index, index) pairs. The matching brackets at
the indexes need to match. Non-semantic tokens are filtered out from the
expected values.
"""
actual = []
- for uwl in uwlines:
+ for lline in llines:
filtered_values = [(ft, ft.matching_bracket)
- for ft in uwl.tokens
+ for ft in lline.tokens
if ft.name not in pytree_utils.NONSEMANTIC_TOKENS]
if filtered_values:
actual.append(filtered_values)
for index, bracket_list in enumerate(list_of_expected):
- uwline = actual[index]
+ lline = actual[index]
if not bracket_list:
- for value in uwline:
+ for value in lline:
self.assertIsNone(value[1])
else:
for open_bracket, close_bracket in bracket_list:
- self.assertEqual(uwline[open_bracket][0], uwline[close_bracket][1])
- self.assertEqual(uwline[close_bracket][0], uwline[open_bracket][1])
+ self.assertEqual(lline[open_bracket][0], lline[close_bracket][1])
+ self.assertEqual(lline[close_bracket][0], lline[open_bracket][1])
def testFunctionDef(self):
code = textwrap.dedent("""\
def foo(a, b=['w','d'], c=[42, 37]):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckMatchingBrackets(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckMatchingBrackets(llines, [
[(2, 20), (7, 11), (15, 19)],
[],
])
@@ -333,8 +333,8 @@ class MatchBracketsTest(yapf_test_helper.YAPFTest):
def foo(a, b, c):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckMatchingBrackets(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckMatchingBrackets(llines, [
[(2, 3)],
[(2, 8)],
[],
@@ -345,8 +345,8 @@ class MatchBracketsTest(yapf_test_helper.YAPFTest):
class A(B, C, D):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckMatchingBrackets(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckMatchingBrackets(llines, [
[(2, 8)],
[],
])
diff --git a/yapftests/reformatter_basic_test.py b/yapftests/reformatter_basic_test.py
index 539aa10..5037f11 100644
--- a/yapftests/reformatter_basic_test.py
+++ b/yapftests/reformatter_basic_test.py
@@ -43,8 +43,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
"whatever": 120
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
yes = { 'yes': 'no', 'no': 'yes', }
@@ -55,8 +55,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
'no': 'yes',
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
def foo(long_arg, really_long_arg, really_really_long_arg, cant_keep_all_these_args):
pass
@@ -68,8 +68,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
cant_keep_all_these_args):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
foo_tuple = [long_arg, really_long_arg, really_really_long_arg, cant_keep_all_these_args]
""") # noqa
@@ -81,16 +81,16 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
cant_keep_all_these_args
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
foo_tuple = [short, arg]
""")
expected_formatted_code = textwrap.dedent("""\
foo_tuple = [short, arg]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
# There is a test for split_all_top_level_comma_separated_values, with
# different expected value
unformatted_code = textwrap.dedent("""\
@@ -103,8 +103,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
abc=(a,
this_will_just_fit_xxxxxxx))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplittingTopLevelAllArgs(self):
style.SetGlobalStyle(
@@ -122,8 +122,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
"whatever": 120
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
# Works the same way as split_all_comma_separated_values
unformatted_code = textwrap.dedent("""\
def foo(long_arg, really_long_arg, really_really_long_arg, cant_keep_all_these_args):
@@ -136,8 +136,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
cant_keep_all_these_args):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
# Works the same way as split_all_comma_separated_values
unformatted_code = textwrap.dedent("""\
foo_tuple = [long_arg, really_long_arg, really_really_long_arg, cant_keep_all_these_args]
@@ -150,8 +150,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
cant_keep_all_these_args
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
# Works the same way as split_all_comma_separated_values
unformatted_code = textwrap.dedent("""\
foo_tuple = [short, arg]
@@ -159,8 +159,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
expected_formatted_code = textwrap.dedent("""\
foo_tuple = [short, arg]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
# There is a test for split_all_comma_separated_values, with different
# expected value
unformatted_code = textwrap.dedent("""\
@@ -172,8 +172,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
this_is_a_very_long_parameter,
abc=(a, this_will_just_fit_xxxxxxx))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- actual_formatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ actual_formatted_code = reformatter.Reformat(llines)
self.assertEqual(40, len(actual_formatted_code.splitlines()[-1]))
self.assertCodeEqual(expected_formatted_code, actual_formatted_code)
@@ -187,8 +187,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
abc=(a,
this_will_not_fit_xxxxxxxxx))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
# Exercise the case where there's no opening bracket (for a, b)
unformatted_code = textwrap.dedent("""\
@@ -199,8 +199,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
a, b = f(
a_very_long_parameter, yet_another_one, and_another)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
# Don't require splitting before comments.
unformatted_code = textwrap.dedent("""\
@@ -221,8 +221,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
'JKL': Jkl,
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSimpleFunctionsWithTrailingComments(self):
unformatted_code = textwrap.dedent("""\
@@ -250,8 +250,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testBlankLinesBetweenTopLevelImportsAndVariables(self):
unformatted_code = textwrap.dedent("""\
@@ -263,8 +263,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
VAR = 'baz'
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
import foo as bar
@@ -282,9 +282,9 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
style.CreateStyleFromConfig(
'{based_on_style: yapf, '
'blank_lines_between_top_level_imports_and_variables: 2}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -296,8 +296,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
import foo as bar
# Some comment
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
import foo as bar
@@ -311,8 +311,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
class Baz():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
import foo as bar
@@ -326,8 +326,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
def foobar():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
def foobar():
@@ -339,8 +339,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
from foo import Bar
Bar.baz()
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testBlankLinesAtEndOfFile(self):
unformatted_code = textwrap.dedent("""\
@@ -354,8 +354,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
def foobar(): # foo
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
x = { 'a':37,'b':42,
@@ -366,8 +366,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
expected_formatted_code = textwrap.dedent("""\
x = {'a': 37, 'b': 42, 'c': 927}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testIndentBlankLines(self):
unformatted_code = textwrap.dedent("""\
@@ -397,16 +397,16 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
style.CreateStyleFromConfig(
'{based_on_style: yapf, indent_blank_lines: true}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
unformatted_code, expected_formatted_code = (expected_formatted_code,
unformatted_code)
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testMultipleUgliness(self):
unformatted_code = textwrap.dedent("""\
@@ -445,8 +445,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
def f(a):
return 37 + -+a[42 - x:y**3]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testComments(self):
unformatted_code = textwrap.dedent("""\
@@ -498,15 +498,15 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
class Qux(object):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSingleComment(self):
code = textwrap.dedent("""\
# Thing 1
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testCommentsWithTrailingSpaces(self):
unformatted_code = textwrap.dedent("""\
@@ -515,8 +515,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
# Thing 1
# Thing 2
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testCommentsInDataLiteral(self):
code = textwrap.dedent("""\
@@ -532,8 +532,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
# Ending comment.
})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testEndingWhitespaceAfterSimpleStatement(self):
code = textwrap.dedent("""\
@@ -541,8 +541,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
# Thing 1
# Thing 2
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testDocstrings(self):
unformatted_code = textwrap.dedent('''\
@@ -579,8 +579,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
print('hello {}'.format('world'))
return 42
''')
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDocstringAndMultilineComment(self):
unformatted_code = textwrap.dedent('''\
@@ -614,8 +614,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
# comment
pass
''')
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testMultilineDocstringAndMultilineComment(self):
unformatted_code = textwrap.dedent('''\
@@ -667,8 +667,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
# comment
pass
''')
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testTupleCommaBeforeLastParen(self):
unformatted_code = textwrap.dedent("""\
@@ -677,8 +677,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
expected_formatted_code = textwrap.dedent("""\
a = (1,)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNoBreakOutsideOfBracket(self):
# FIXME(morbo): How this is formatted is not correct. But it's syntactically
@@ -693,8 +693,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
assert port >= minimum, 'Unexpected port %d when minimum was %d.' % (port,
minimum)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testBlankLinesBeforeDecorators(self):
unformatted_code = textwrap.dedent("""\
@@ -714,8 +714,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
def x(self):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testCommentBetweenDecorators(self):
unformatted_code = textwrap.dedent("""\
@@ -732,8 +732,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
def x(self):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testListComprehension(self):
unformatted_code = textwrap.dedent("""\
@@ -745,8 +745,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
def given(y):
[k for k in () if k in y]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testListComprehensionPreferOneLine(self):
unformatted_code = textwrap.dedent("""\
@@ -762,8 +762,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
long_var_name + 1 for long_var_name in () if long_var_name == 2
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testListComprehensionPreferOneLineOverArithmeticSplit(self):
unformatted_code = textwrap.dedent("""\
@@ -776,8 +776,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
return (sum(len(identifier) for identifier in used_identifiers) /
len(used_identifiers))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testListComprehensionPreferThreeLinesForLineWrap(self):
unformatted_code = textwrap.dedent("""\
@@ -795,8 +795,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
if long_var_name == 2 and number_two == 3
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testListComprehensionPreferNoBreakForTrivialExpression(self):
unformatted_code = textwrap.dedent("""\
@@ -813,8 +813,8 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
if long_var_name == 2 and number_two == 3
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testOpeningAndClosingBrackets(self):
unformatted_code = """\
@@ -831,8 +831,8 @@ foo((
3,
))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSingleLineFunctions(self):
unformatted_code = textwrap.dedent("""\
@@ -842,8 +842,8 @@ foo((
def foo():
return 42
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNoQueueSeletionInMiddleOfLine(self):
# If the queue isn't properly constructed, then a token in the middle of the
@@ -856,8 +856,8 @@ find_symbol(node.type) + "< " + " ".join(find_pattern(n) for n in node.child) +
find_symbol(node.type) + "< " + " ".join(
find_pattern(n) for n in node.child) + " >"
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNoSpacesBetweenSubscriptsAndCalls(self):
unformatted_code = textwrap.dedent("""\
@@ -866,8 +866,8 @@ find_symbol(node.type) + "< " + " ".join(
expected_formatted_code = textwrap.dedent("""\
aaaaaaaaaa = bbbbbbbb.ccccccccc()[42](a, 2)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNoSpacesBetweenOpeningBracketAndStartingOperator(self):
# Unary operator.
@@ -877,8 +877,8 @@ find_symbol(node.type) + "< " + " ".join(
expected_formatted_code = textwrap.dedent("""\
aaaaaaaaaa = bbbbbbbb.ccccccccc[-1](-42)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
# Varargs and kwargs.
unformatted_code = textwrap.dedent("""\
@@ -889,8 +889,8 @@ find_symbol(node.type) + "< " + " ".join(
aaaaaaaaaa = bbbbbbbb.ccccccccc(*varargs)
aaaaaaaaaa = bbbbbbbb.ccccccccc(**kwargs)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testMultilineCommentReformatted(self):
unformatted_code = textwrap.dedent("""\
@@ -905,8 +905,8 @@ find_symbol(node.type) + "< " + " ".join(
# comment.
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDictionaryMakerFormatting(self):
unformatted_code = textwrap.dedent("""\
@@ -930,8 +930,8 @@ find_symbol(node.type) + "< " + " ".join(
'while_stmt': 'for_stmt',
})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSimpleMultilineCode(self):
unformatted_code = textwrap.dedent("""\
@@ -948,8 +948,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
aaaaaaaaaaaaaa.bbbbbbbbbbbbbb.ccccccc(zzzzzzzzzzzz, xxxxxxxxxxx, yyyyyyyyyyyy,
vvvvvvvvv)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testMultilineComment(self):
code = textwrap.dedent("""\
@@ -961,15 +961,15 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
# Yo man.
a = 42
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testSpaceBetweenStringAndParentheses(self):
code = textwrap.dedent("""\
b = '0' ('hello')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testMultilineString(self):
code = textwrap.dedent("""\
@@ -983,8 +983,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
a = 42
''')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent('''\
def f():
@@ -1004,8 +1004,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
</body>
</html>"""
''') # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSimpleMultilineWithComments(self):
code = textwrap.dedent("""\
@@ -1016,8 +1016,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
# Whoa! A normal comment!!
pass # Another trailing comment
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testMatchingParenSplittingMatching(self):
unformatted_code = textwrap.dedent("""\
@@ -1030,8 +1030,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
raise RuntimeError('unable to find insertion point for target node',
(target,))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testContinuationIndent(self):
unformatted_code = textwrap.dedent('''\
@@ -1056,8 +1056,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
subtype=_ARGLIST_TOKEN_TO_SUBTYPE.get(child.value,
format_token.Subtype.NONE))
''') # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testTrailingCommaAndBracket(self):
unformatted_code = textwrap.dedent('''\
@@ -1074,21 +1074,21 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
42,
]
''')
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testI18n(self):
code = textwrap.dedent("""\
N_('Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.') # A comment is here.
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
code = textwrap.dedent("""\
foo('Fake function call') #. Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testI18nCommentsInDataLiteral(self):
code = textwrap.dedent("""\
@@ -1101,8 +1101,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
'snork': 'bar#.*=\\\\0',
})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testClosingBracketIndent(self):
code = textwrap.dedent('''\
@@ -1114,8 +1114,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb'):
pass
''') # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testClosingBracketsInlinedInCall(self):
unformatted_code = textwrap.dedent("""\
@@ -1146,8 +1146,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
"porkporkpork": 5,
})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testLineWrapInForExpression(self):
code = textwrap.dedent("""\
@@ -1159,8 +1159,8 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
node.pre_order())):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testFunctionCallContinuationLine(self):
code = """\
@@ -1173,8 +1173,8 @@ class foo:
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
cccc, ddddddddddddddddddddddddddddddddddddd))]
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testI18nNonFormatting(self):
code = textwrap.dedent("""\
@@ -1185,16 +1185,16 @@ class foo:
message=N_('Please check your email address.'), **kwargs):
pass
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testNoSpaceBetweenUnaryOpAndOpeningParen(self):
code = textwrap.dedent("""\
if ~(a or b):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testCommentBeforeFuncDef(self):
code = textwrap.dedent("""\
@@ -1211,8 +1211,8 @@ class foo:
bbbbbbbbbbbbbbb=False):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testExcessLineCountWithDefaultKeywords(self):
unformatted_code = textwrap.dedent("""\
@@ -1236,16 +1236,16 @@ class foo:
hhhhhhhhhhhhh=hhhhhhhhhhhhh,
iiiiiii=iiiiiiiiiiiiii)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSpaceAfterNotOperator(self):
code = textwrap.dedent("""\
if not (this and that):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testNoPenaltySplitting(self):
code = textwrap.dedent("""\
@@ -1257,8 +1257,8 @@ class foo:
for f in os.listdir(filename)
if IsPythonFile(os.path.join(filename, f)))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testExpressionPenalties(self):
code = textwrap.dedent("""\
@@ -1268,8 +1268,8 @@ class foo:
(left.value == '{' and right.value == '}')):
return False
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testLineDepthOfSingleLineStatement(self):
unformatted_code = textwrap.dedent("""\
@@ -1291,8 +1291,8 @@ class foo:
with open(a) as fd:
a = fd.read()
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplitListWithTerminatingComma(self):
unformatted_code = textwrap.dedent("""\
@@ -1314,8 +1314,8 @@ class foo:
lambda a, b: 37,
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplitListWithInterspersedComments(self):
code = textwrap.dedent("""\
@@ -1333,15 +1333,15 @@ class foo:
lambda a, b: 37 # lambda
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testRelativeImportStatements(self):
code = textwrap.dedent("""\
from ... import bork
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testSingleLineList(self):
# A list on a single line should prefer to remain contiguous.
@@ -1355,8 +1355,8 @@ class foo:
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = aaaaaaaaaaa(
("...", "."), "..", "..............................................")
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testBlankLinesBeforeFunctionsNotInColumnZero(self):
unformatted_code = textwrap.dedent("""\
@@ -1389,8 +1389,8 @@ class foo:
except:
pass
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNoKeywordArgumentBreakage(self):
code = textwrap.dedent("""\
@@ -1401,8 +1401,8 @@ class foo:
cccccccccccccccccccc=True):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testTrailerOnSingleLine(self):
code = """\
@@ -1411,8 +1411,8 @@ urlpatterns = patterns('', url(r'^$', 'homepage_view'),
url(r'^/login/$', 'logout_view'),
url(r'^/user/(?P<username>\\w+)/$', 'profile_view'))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testIfConditionalParens(self):
code = textwrap.dedent("""\
@@ -1424,8 +1424,8 @@ urlpatterns = patterns('', url(r'^$', 'homepage_view'),
child.value in substatement_names):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testContinuationMarkers(self):
code = textwrap.dedent("""\
@@ -1435,23 +1435,23 @@ urlpatterns = patterns('', url(r'^$', 'homepage_view'),
"sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. "\\
"Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet"
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
code = textwrap.dedent("""\
from __future__ import nested_scopes, generators, division, absolute_import, with_statement, \\
print_function, unicode_literals
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
code = textwrap.dedent("""\
if aaaaaaaaa == 42 and bbbbbbbbbbbbbb == 42 and \\
cccccccc == 42:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testCommentsWithContinuationMarkers(self):
code = textwrap.dedent("""\
@@ -1461,8 +1461,8 @@ urlpatterns = patterns('', url(r'^$', 'homepage_view'),
key2=arg)\\
.fn3()
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testMultipleContinuationMarkers(self):
code = textwrap.dedent("""\
@@ -1470,8 +1470,8 @@ urlpatterns = patterns('', url(r'^$', 'homepage_view'),
\\
some_thing()
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testContinuationMarkerAfterStringWithContinuation(self):
code = """\
@@ -1479,8 +1479,8 @@ s = 'foo \\
bar' \\
.format()
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testEmptyContainers(self):
code = textwrap.dedent("""\
@@ -1489,8 +1489,8 @@ s = 'foo \\
'Lorem ipsum dolor sit amet, consetetur adipiscing elit. Donec a diam lectus. '
'Sed sit amet ipsum mauris. Maecenas congue.')
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testSplitStringsIfSurroundedByParens(self):
unformatted_code = textwrap.dedent("""\
@@ -1504,16 +1504,16 @@ s = 'foo \\
'cccccccccccccccccccccccccccccccc'
'ddddddddddddddddddddddddddddd')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
code = textwrap.dedent("""\
a = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' \
'bbbbbbbbbbbbbbbbbbbbbbbbbb' 'cccccccccccccccccccccccccccccccc' \
'ddddddddddddddddddddddddddddd'
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testMultilineShebang(self):
code = textwrap.dedent("""\
@@ -1532,16 +1532,16 @@ s = 'foo \\
assert os.environ['FOO'] == '123'
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testNoSplittingAroundTermOperators(self):
code = textwrap.dedent("""\
a_very_long_function_call_yada_yada_etc_etc_etc(long_arg1,
long_arg2 / long_arg3)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testNoSplittingWithinSubscriptList(self):
code = textwrap.dedent("""\
@@ -1550,8 +1550,8 @@ s = 'foo \\
'someotherlongkey': 2
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testExcessCharacters(self):
code = textwrap.dedent("""\
@@ -1562,8 +1562,8 @@ s = 'foo \\
'%s%s %s' % ('many of really', 'long strings', '+ just makes up 81')
])
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
def _():
@@ -1580,8 +1580,8 @@ s = 'foo \\
if_attribute) == has_value:
return True
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
def testDictSetGenerator(self):
code = textwrap.dedent("""\
@@ -1591,8 +1591,8 @@ s = 'foo \\
if variable != 37
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testUnaryOpInDictionaryValue(self):
code = textwrap.dedent("""\
@@ -1602,8 +1602,8 @@ s = 'foo \\
print(beta[-1])
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testUnaryNotOperator(self):
code = textwrap.dedent("""\
@@ -1614,8 +1614,8 @@ s = 'foo \\
remote_checksum = self.get_checksum(conn, tmp, dest, inject,
not directory_prepended, source)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testRelaxArraySubscriptAffinity(self):
code = """\
@@ -1630,18 +1630,18 @@ class A(object):
bbbbbbbbbbbbb[
'..............'] = row[5] if row[5] is not None else 5
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testFunctionCallInDict(self):
code = "a = {'a': b(c=d, **e)}\n"
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testFunctionCallInNestedDict(self):
code = "a = {'a': {'a': {'a': b(c=d, **e)}}}\n"
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testUnbreakableNot(self):
code = textwrap.dedent("""\
@@ -1649,8 +1649,8 @@ class A(object):
if not "Foooooooooooooooooooooooooooooo" or "Foooooooooooooooooooooooooooooo" == "Foooooooooooooooooooooooooooooo":
pass
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testSplitListWithComment(self):
code = textwrap.dedent("""\
@@ -1660,8 +1660,8 @@ class A(object):
'c' # hello world
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testOverColumnLimit(self):
unformatted_code = textwrap.dedent("""\
@@ -1687,8 +1687,8 @@ class A(object):
'ccccccccccccccccccccccccccccccccccccccccccc',
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testEndingComment(self):
code = textwrap.dedent("""\
@@ -1697,8 +1697,8 @@ class A(object):
b="something requiring comment which is quite long", # comment about b (pushes line over 79)
c="something else, about which comment doesn't make sense")
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testContinuationSpaceRetention(self):
code = textwrap.dedent("""\
@@ -1708,8 +1708,8 @@ class A(object):
fn2(arg)
))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testIfExpressionWithFunctionCall(self):
code = textwrap.dedent("""\
@@ -1720,8 +1720,8 @@ class A(object):
bbbbbbbbbbbbbbbbbbbbb=bbbbbbbbbbbbbbbbbb):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testUnformattedAfterMultilineString(self):
code = textwrap.dedent("""\
@@ -1731,8 +1731,8 @@ class A(object):
TEST
''' % (input_fname, output_fname)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testNoSpacesAroundKeywordDefaultValues(self):
code = textwrap.dedent("""\
@@ -1742,8 +1742,8 @@ class A(object):
}
json = request.get_json(silent=True) or {}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testNoSplittingBeforeEndingSubscriptBracket(self):
unformatted_code = textwrap.dedent("""\
@@ -1757,8 +1757,8 @@ class A(object):
status = cf.describe_stacks(
StackName=stackname)[u'Stacks'][0][u'StackStatus']
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNoSplittingOnSingleArgument(self):
unformatted_code = textwrap.dedent("""\
@@ -1779,8 +1779,8 @@ class A(object):
re.search(r'(\\d+\\.\\d+\\.\\d+\\.)\\d+', aaaaaaa.bbbbbbbbbbbb).group(a.b) +
re.search(r'\\d+\\.\\d+\\.\\d+\\.(\\d+)', ccccccc).group(c.d))
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplittingArraysSensibly(self):
unformatted_code = textwrap.dedent("""\
@@ -1797,8 +1797,8 @@ class A(object):
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = list(
'bbbbbbbbbbbbbbbbbbbbbbbbb').split(',')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testComprehensionForAndIf(self):
unformatted_code = textwrap.dedent("""\
@@ -1814,8 +1814,8 @@ class A(object):
tokens_repr = ','.join(
['{0}({1!r})'.format(tok.name, tok.value) for tok in self._tokens])
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testFunctionCallArguments(self):
unformatted_code = textwrap.dedent("""\
@@ -1839,8 +1839,8 @@ class A(object):
_CreateCommentsFromPrefix(
comment_prefix, comment_lineno, comment_column, standalone=True))
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testBinaryOperators(self):
unformatted_code = textwrap.dedent("""\
@@ -1851,8 +1851,8 @@ class A(object):
a = b**37
c = (20**-3) / (_GRID_ROWS**(code_length - 10))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
code = textwrap.dedent("""\
def f():
@@ -1863,16 +1863,16 @@ class A(object):
current.value in ']}'):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testContiguousList(self):
code = textwrap.dedent("""\
[retval1, retval2] = a_very_long_function(argument_1, argument2, argument_3,
argument_4)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testArgsAndKwargsFormatting(self):
code = textwrap.dedent("""\
@@ -1882,8 +1882,8 @@ class A(object):
*d,
**e)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
code = textwrap.dedent("""\
def foo():
@@ -1893,8 +1893,8 @@ class A(object):
zzz='a third long string')
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testCommentColumnLimitOverflow(self):
code = textwrap.dedent("""\
@@ -1906,8 +1906,8 @@ class A(object):
# side_effect=[(157031694470475), (157031694470475),],
)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testMultilineLambdas(self):
unformatted_code = textwrap.dedent("""\
@@ -1938,9 +1938,9 @@ class A(object):
style.SetGlobalStyle(
style.CreateStyleFromConfig(
'{based_on_style: yapf, allow_multiline_lambdas: true}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -1971,9 +1971,9 @@ class A(object):
style.SetGlobalStyle(
style.CreateStyleFromConfig('{based_on_style: yapf, '
'allow_multiline_dictionary_keys: true}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -1999,12 +1999,12 @@ class A(object):
'continuation_indent_width: 4, '
'indent_dictionary_value: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(code, reformatted_code)
- uwlines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(code, reformatted_code)
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2026,12 +2026,12 @@ class A(object):
}))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(expected_formatted_code, reformatted_code)
- uwlines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(expected_formatted_code, reformatted_code)
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2047,8 +2047,8 @@ class A(object):
_connect.execute(
_games.update().where(_games.c.gid == gid).values(scored=True))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDontAddBlankLineAfterMultilineString(self):
code = textwrap.dedent("""\
@@ -2057,8 +2057,8 @@ class A(object):
WHERE day in {}'''
days = ",".join(days)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testFormattingListComprehensions(self):
code = textwrap.dedent("""\
@@ -2071,8 +2071,8 @@ class A(object):
]
self._heap = [x for x in self._heap if x.route and x.route[0] == choice]
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testNoSplittingWhenBinPacking(self):
code = textwrap.dedent("""\
@@ -2097,12 +2097,12 @@ class A(object):
'dedent_closing_brackets: True, '
'split_before_named_assigns: False}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(code, reformatted_code)
- uwlines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(code, reformatted_code)
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2118,8 +2118,8 @@ class A(object):
c == d['eeeeee']).ffffff():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplittingOneArgumentList(self):
unformatted_code = textwrap.dedent("""\
@@ -2141,8 +2141,8 @@ class A(object):
boxes[id_] = np.concatenate(
(points.min(axis=0), qoints.max(axis=0)))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplittingBeforeFirstElementListArgument(self):
unformatted_code = textwrap.dedent("""\
@@ -2170,8 +2170,8 @@ class A(object):
(clue for clue in combination if not clue == Verifier.UNMATCHED),
constraints, InvestigationResult.OR)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplittingArgumentsTerminatedByComma(self):
unformatted_code = textwrap.dedent("""\
@@ -2220,12 +2220,12 @@ class A(object):
'{based_on_style: yapf, '
'split_arguments_when_comma_terminated: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(expected_formatted_code, reformatted_code)
- uwlines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(expected_formatted_code, reformatted_code)
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2236,8 +2236,8 @@ class A(object):
from toto import titi, tata, tutu
from toto import (titi, tata, tutu)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testDictionaryValuesOnOwnLines(self):
unformatted_code = textwrap.dedent("""\
@@ -2288,8 +2288,8 @@ class A(object):
Check('QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ', '=', False),
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDictionaryOnOwnLine(self):
unformatted_code = textwrap.dedent("""\
@@ -2302,8 +2302,8 @@ class A(object):
doc = test_utils.CreateTestDocumentViaController(
content={'a': 'b'}, branch_key=branch.key, collection_key=collection.key)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
doc = test_utils.CreateTestDocumentViaController(
@@ -2319,8 +2319,8 @@ class A(object):
collection_key=collection.key,
collection_key2=collection.key2)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNestedListsInDictionary(self):
unformatted_code = textwrap.dedent("""\
@@ -2386,8 +2386,8 @@ class A(object):
),
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNestedDictionary(self):
unformatted_code = textwrap.dedent("""\
@@ -2414,8 +2414,8 @@ class A(object):
]
breadcrumbs = [{'name': 'Admin', 'url': url_for(".home")}, {'title': title}]
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDictionaryElementsOnOneLine(self):
code = textwrap.dedent("""\
@@ -2434,8 +2434,8 @@ class A(object):
Environment.ZZZZZZZZZZZ: 'some text more text even more text yet again tex',
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testNotInParams(self):
unformatted_code = textwrap.dedent("""\
@@ -2445,8 +2445,8 @@ class A(object):
list("a long line to break the line. a long line to break the brk a long lin",
not True)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
def testNamedAssignNotAtEndOfLine(self):
unformatted_code = textwrap.dedent("""\
@@ -2463,8 +2463,8 @@ class A(object):
filename, mode='w', encoding=encoding) as fd:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
def testBlankLineBeforeClassDocstring(self):
unformatted_code = textwrap.dedent('''\
@@ -2488,8 +2488,8 @@ class A(object):
def __init__(self):
pass
''')
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent('''\
class A:
@@ -2520,9 +2520,9 @@ class A(object):
'{based_on_style: yapf, '
'blank_line_before_class_docstring: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2546,8 +2546,8 @@ class A(object):
def foobar():
pass
''')
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent('''\
#!/usr/bin/env python
@@ -2575,9 +2575,9 @@ class A(object):
'{based_on_style: pep8, '
'blank_line_before_module_docstring: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2593,15 +2593,15 @@ class A(object):
an_extremely_long_variable_name,
('a string that may be too long %s' % 'M15'))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
def testSubscriptExpression(self):
code = textwrap.dedent("""\
foo = d[not a]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testListWithFunctionCalls(self):
unformatted_code = textwrap.dedent("""\
@@ -2627,8 +2627,8 @@ class A(object):
zzz='a third long string')
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
def testEllipses(self):
unformatted_code = textwrap.dedent("""\
@@ -2639,8 +2639,8 @@ class A(object):
X = ...
Y = X if ... else X
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
def testPseudoParens(self):
unformatted_code = """\
@@ -2657,8 +2657,8 @@ my_dict = {
},
}
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
def testSplittingBeforeFirstArgumentOnFunctionCall(self):
"""Tests split_before_first_argument on a function call."""
@@ -2676,9 +2676,9 @@ my_dict = {
style.CreateStyleFromConfig(
'{based_on_style: yapf, split_before_first_argument: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2700,9 +2700,9 @@ my_dict = {
style.CreateStyleFromConfig(
'{based_on_style: yapf, split_before_first_argument: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2726,9 +2726,9 @@ my_dict = {
style.CreateStyleFromConfig(
'{based_on_style: yapf, split_before_first_argument: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2762,9 +2762,9 @@ my_dict = {
style.CreateStyleFromConfig(
'{based_on_style: yapf, coalesce_brackets: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2783,8 +2783,8 @@ my_dict = {
style.CreateStyleFromConfig(
'{based_on_style: yapf, coalesce_brackets: True, '
'dedent_closing_brackets: true}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2804,8 +2804,8 @@ my_dict = {
async.run()
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2819,8 +2819,8 @@ my_dict = {
style.CreateStyleFromConfig('{based_on_style: yapf,'
' disable_ending_comma_heuristic: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2851,9 +2851,9 @@ my_dict = {
style.CreateStyleFromConfig('{based_on_style: yapf,'
' dedent_closing_brackets: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2884,9 +2884,9 @@ my_dict = {
style.CreateStyleFromConfig('{based_on_style: yapf,'
' indent_closing_brackets: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2919,9 +2919,9 @@ my_dict = {
style.CreateStyleFromConfig('{based_on_style: yapf,'
' indent_closing_brackets: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2954,9 +2954,9 @@ my_dict = {
style.CreateStyleFromConfig('{based_on_style: yapf,'
' indent_closing_brackets: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -2989,9 +2989,9 @@ my_dict = {
style.CreateStyleFromConfig('{based_on_style: yapf,'
' indent_closing_brackets: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -3030,9 +3030,9 @@ my_dict = {
style.CreateStyleFromConfig('{based_on_style: yapf,'
' indent_closing_brackets: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -3086,8 +3086,8 @@ my_dict = {
}]
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testForceMultilineDict_True(self):
try:
@@ -3095,8 +3095,8 @@ my_dict = {
style.CreateStyleFromConfig('{force_multiline_dict: true}'))
unformatted_code = textwrap.dedent(
"responseDict = {'childDict': {'spam': 'eggs'}}\n")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- actual = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ actual = reformatter.Reformat(llines)
expected = textwrap.dedent("""\
responseDict = {
'childDict': {
@@ -3116,9 +3116,9 @@ my_dict = {
responseDict = {'childDict': {'spam': 'eggs'}}
""")
expected_formatted_code = unformatted_code
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -3132,8 +3132,8 @@ my_dict = {
if (x := len([1] * 1000) > 100):
print(f'{x} is pretty big')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected, reformatter.Reformat(llines))
if __name__ == '__main__':
diff --git a/yapftests/reformatter_buganizer_test.py b/yapftests/reformatter_buganizer_test.py
index a324444..b3de8f9 100644
--- a/yapftests/reformatter_buganizer_test.py
+++ b/yapftests/reformatter_buganizer_test.py
@@ -35,8 +35,8 @@ def _create_testing_simulator_and_sink(
_batch_simulator.SimulationSink]:
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB73279849(self):
unformatted_code = """\
@@ -49,8 +49,8 @@ class A:
def _(a):
return 'hello'[a]
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB122455211(self):
unformatted_code = """\
@@ -62,8 +62,8 @@ _zzzzzzzzzzzzzzzzzzzz = Union[
sssssssssssssssssssss.pppppppppppppppp,
sssssssssssssssssssss.pppppppppppppppppppppppppppp]
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB119300344(self):
code = """\
@@ -73,8 +73,8 @@ def _GenerateStatsEntries(
) -> Sequence[stats_values.StatsStoreEntry]:
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB132886019(self):
code = """\
@@ -86,8 +86,8 @@ X = {
]),
}
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB26521719(self):
code = """\
@@ -97,8 +97,8 @@ class _():
self.stubs.Set(some_type_of_arg, 'ThisIsAStringArgument',
lambda *unused_args, **unused_kwargs: fake_resolver)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB122541552(self):
code = """\
@@ -110,8 +110,8 @@ _QUERY = account.Account.query(account.Account.enabled == True)
def _():
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB124415889(self):
code = """\
@@ -133,8 +133,8 @@ class _():
})
return modules
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB73166511(self):
code = """\
@@ -143,8 +143,8 @@ def _():
groundtruth_age_variances = tf.maximum(groundtruth_age_variances,
min_std**2)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB118624921(self):
code = """\
@@ -156,8 +156,8 @@ def _():
metric='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
bork=foo)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB35417079(self):
code = """\
@@ -171,8 +171,8 @@ class _():
'CopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybara' # copybara:strip
)
""" # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB120047670(self):
unformatted_code = """\
@@ -195,8 +195,8 @@ X = {
'PING_BLOCKED_BUGS': False,
}
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB120245013(self):
unformatted_code = """\
@@ -213,8 +213,8 @@ class Foo(object):
self._fillInOtherFields(streamz_path, {streamz_field_of_interest: True}
)] = series.Counter('1s', '+ 500x10000')
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB117841880(self):
code = """\
@@ -230,8 +230,8 @@ def xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
) -> pd.DataFrame:
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB111764402(self):
unformatted_code = """\
@@ -244,16 +244,16 @@ x = self.stubs.stub(video_classification_map, 'read_video_classifications',
for external_id in external_ids
}))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB116825060(self):
code = """\
result_df = pd.DataFrame({LEARNED_CTR_COLUMN: learned_ctr},
index=df_metrics.index)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB112711217(self):
code = """\
@@ -261,8 +261,8 @@ def _():
stats['moderated'] = ~stats.moderation_reason.isin(
approved_moderation_reasons)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB112867548(self):
unformatted_code = """\
@@ -283,8 +283,8 @@ def _():
httplib.ACCEPTED if process_result.has_more else httplib.OK,
{'content-type': _TEXT_CONTEXT_TYPE})
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB112651423(self):
unformatted_code = """\
@@ -302,8 +302,8 @@ def potato(feeditems, browse_use_case=None):
'FEEDS_LOAD_PLAYLIST_VIDEOS_FOR_ALL_ITEMS'] and item.video:
continue
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB80484938(self):
code = """\
@@ -345,8 +345,8 @@ for sssssss, aaaaaaaaaa in [
]:
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB120771563(self):
code = """\
@@ -372,8 +372,8 @@ class A:
}]
}
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB79462249(self):
code = """\
@@ -394,8 +394,8 @@ foo.bar(
bbbbbbbbbbbbbbbbbbbbb=2,
ccccccccccccccccccc=3)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB113210278(self):
unformatted_code = """\
@@ -410,8 +410,8 @@ def _():
eeeeeeeeeeeeeeeeeeeeeeeeee.fffffffffffffffffffffffffffffffffffffff
.ggggggggggggggggggggggggggggggggg.hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh())
""" # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB77923341(self):
code = """\
@@ -420,8 +420,8 @@ def f():
ddddddddddd.eeeeeeeee == constants.FFFFFFFFFFFFFF):
raise "yo"
""" # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB77329955(self):
code = """\
@@ -438,8 +438,8 @@ class _():
def _():
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB65197969(self):
unformatted_code = """\
@@ -457,8 +457,8 @@ class _():
seconds=max(float(time_scale), small_interval) *
1.41**min(num_attempts, 9))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB65546221(self):
unformatted_code = """\
@@ -484,8 +484,8 @@ SUPPORTED_PLATFORMS = (
"debian-9-stretch",
)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB30500455(self):
unformatted_code = """\
@@ -501,8 +501,8 @@ INITIAL_SYMTAB = dict(
[(name, 'function#' + name) for name in INITIAL_FUNCTIONS] +
[(name, 'const#' + name) for name in INITIAL_CONSTS])
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB38343525(self):
code = """\
@@ -513,8 +513,8 @@ INITIAL_SYMTAB = dict(
def f():
print 1
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB37099651(self):
unformatted_code = """\
@@ -534,8 +534,8 @@ _MEMCACHE = lazy.MakeLazy(
# pylint: enable=g-long-lambda
)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB33228502(self):
unformatted_code = """\
@@ -572,8 +572,8 @@ def _():
| m.Join('successes', 'total')
| m.Point(m.VAL['successes'] / m.VAL['total']))))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB30394228(self):
code = """\
@@ -585,8 +585,8 @@ class _():
alert.Format(alert.body, alert=alert, threshold=threshold),
alert.html_formatting)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB65246454(self):
unformatted_code = """\
@@ -605,8 +605,8 @@ class _():
self.assertEqual({i.id for i in successful_instances},
{i.id for i in self._statuses.successful_instances})
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB67935450(self):
unformatted_code = """\
@@ -646,8 +646,8 @@ def _():
m.Cond(m.VAL['start'] != 0, m.VAL['start'],
m.TimestampMicros() / 1000000L)))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB66011084(self):
unformatted_code = """\
@@ -678,8 +678,8 @@ X = {
]),
}
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB67455376(self):
unformatted_code = """\
@@ -689,8 +689,8 @@ sponge_ids.extend(invocation.id() for invocation in self._client.GetInvocationsB
sponge_ids.extend(invocation.id()
for invocation in self._client.GetInvocationsByLabels(labels))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB35210351(self):
unformatted_code = """\
@@ -719,8 +719,8 @@ def _():
GetTheAlertToIt('the_title_to_the_thing_here'),
GetNotificationTemplate('your_email_here')))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB34774905(self):
unformatted_code = """\
@@ -748,15 +748,15 @@ x = [
astn=None))
]
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB65176185(self):
code = """\
xx = zip(*[(a, b) for (a, b, c) in yy])
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB35210166(self):
unformatted_code = """\
@@ -776,8 +776,8 @@ def _():
| o.Window(m.Align('5m'))
| p.GroupBy(['borg_user', 'borg_job', 'borg_cell'], q.Mean()))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB32167774(self):
unformatted_code = """\
@@ -803,8 +803,8 @@ X = (
'is_compilation',
)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB66912275(self):
unformatted_code = """\
@@ -827,8 +827,8 @@ def _():
'fingerprint': base64.urlsafe_b64encode('invalid_fingerprint')
}).execute()
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB67312284(self):
code = """\
@@ -837,8 +837,8 @@ def _():
[u'to be published 2', u'to be published 1', u'to be published 0'],
[el.text for el in page.first_column_tds])
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB65241516(self):
unformatted_code = """\
@@ -850,16 +850,16 @@ checkpoint_files = gfile.Glob(
TrainTraceDir(unit_key, "*", "*"),
embedding_model.CHECKPOINT_FILENAME + "-*"))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB37460004(self):
code = textwrap.dedent("""\
assert all(s not in (_SENTINEL, None) for s in nested_schemas
), 'Nested schemas should never contain None/_SENTINEL'
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB36806207(self):
code = """\
@@ -877,8 +877,8 @@ def _():
"%.1f%%" % (np.max(linearity_values["rot_discontinuity"]) * 100.0)
]]
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB36215507(self):
code = textwrap.dedent("""\
@@ -891,8 +891,8 @@ def _():
*(qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq),
**(qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB35212469(self):
unformatted_code = textwrap.dedent("""\
@@ -913,8 +913,8 @@ def _():
}
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB31063453(self):
unformatted_code = textwrap.dedent("""\
@@ -928,8 +928,8 @@ def _():
((time_time() - last_modified) < FLAGS_boot_idle_timeout)):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB35021894(self):
unformatted_code = textwrap.dedent("""\
@@ -955,8 +955,8 @@ def _():
'modify': 'name/some-other-type-of-very-long-name-for-modifying'
})
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB34682902(self):
unformatted_code = textwrap.dedent("""\
@@ -966,8 +966,8 @@ def _():
logging.info("Mean angular velocity norm: %.3f",
np.linalg.norm(np.mean(ang_vel_arr, axis=0)))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB33842726(self):
unformatted_code = textwrap.dedent("""\
@@ -982,8 +982,8 @@ def _():
hints.append(('hg tag -f -l -r %s %s # %s' %
(short(ctx.node()), candidatetag, firstline))[:78])
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB32931780(self):
unformatted_code = textwrap.dedent("""\
@@ -1044,8 +1044,8 @@ def _():
}
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB33047408(self):
code = textwrap.dedent("""\
@@ -1058,8 +1058,8 @@ def _():
'order': 'ASCENDING'
})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB32714745(self):
code = textwrap.dedent("""\
@@ -1088,8 +1088,8 @@ def _():
'dirty': False,
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB32737279(self):
unformatted_code = textwrap.dedent("""\
@@ -1105,8 +1105,8 @@ def _():
'value'
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB32570937(self):
code = textwrap.dedent("""\
@@ -1116,8 +1116,8 @@ def _():
job_message.mall not in ('*', job_name)):
return False
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB31937033(self):
code = textwrap.dedent("""\
@@ -1126,8 +1126,8 @@ def _():
def __init__(self, metric, fields_cb=None):
self._fields_cb = fields_cb or (lambda *unused_args, **unused_kwargs: {})
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB31911533(self):
code = """\
@@ -1142,8 +1142,8 @@ class _():
def _():
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB31847238(self):
unformatted_code = textwrap.dedent("""\
@@ -1167,8 +1167,8 @@ class _():
zzzzzzzzzzzzzz=None): # A normal comment that runs over the column limit.
return 1
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB30760569(self):
unformatted_code = textwrap.dedent("""\
@@ -1181,8 +1181,8 @@ class _():
'1234567890123456789012345678901234567890'
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB26034238(self):
unformatted_code = textwrap.dedent("""\
@@ -1199,8 +1199,8 @@ class _():
'/aaaaaaaaa/bbbbbbbbbb/ccccc/dddd/eeeeeeeeeeeeee/ffffffffffffff'
).AndReturn(42)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB30536435(self):
unformatted_code = textwrap.dedent("""\
@@ -1220,8 +1220,8 @@ class _():
bbbbbbbbb.usage, ccccccccc.within,
imports.ddddddddddddddddddd(name_item.ffffffffffffffff)))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB30442148(self):
unformatted_code = textwrap.dedent("""\
@@ -1234,8 +1234,8 @@ class _():
return (some_long_module_name.SomeLongClassName.some_long_attribute_name
.some_long_method_name())
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB26868213(self):
unformatted_code = textwrap.dedent("""\
@@ -1270,8 +1270,8 @@ class _():
}
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB30173198(self):
code = textwrap.dedent("""\
@@ -1281,8 +1281,8 @@ class _():
self.assertFalse(
evaluation_runner.get_larps_in_eval_set('these_arent_the_larps'))
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB29908765(self):
code = textwrap.dedent("""\
@@ -1292,8 +1292,8 @@ class _():
return '<session %s on %s>' % (
self._id, self._stub._stub.rpc_channel().target()) # pylint:disable=protected-access
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB30087362(self):
code = textwrap.dedent("""\
@@ -1305,8 +1305,8 @@ class _():
# This is another comment
foo()
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB30087363(self):
code = textwrap.dedent("""\
@@ -1317,8 +1317,8 @@ class _():
elif True:
foo()
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB29093579(self):
unformatted_code = textwrap.dedent("""\
@@ -1333,8 +1333,8 @@ class _():
bbbbbbbbbbbbbb.cccccccccc[dddddddddddddddddddddddddddd
.eeeeeeeeeeeeeeeeeeeeee.fffffffffffffffffffff])
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB26382315(self):
code = textwrap.dedent("""\
@@ -1345,8 +1345,8 @@ class _():
def foo():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB27616132(self):
unformatted_code = textwrap.dedent("""\
@@ -1368,8 +1368,8 @@ class _():
mock.call(100, start_cursor=cursor_2),
])
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB27590179(self):
unformatted_code = textwrap.dedent("""\
@@ -1392,8 +1392,8 @@ class _():
self.bbb.cccccccccc(ddddddddddddddddddddddd.eeeeeeeeeeeeeeeeeeeeee)
})
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB27266946(self):
unformatted_code = textwrap.dedent("""\
@@ -1406,8 +1406,8 @@ class _():
self.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
.cccccccccccccccccccccccccccccccccccc)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB25505359(self):
code = textwrap.dedent("""\
@@ -1421,8 +1421,8 @@ class _():
}]
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB25324261(self):
code = textwrap.dedent("""\
@@ -1430,8 +1430,8 @@ class _():
for ddd in eeeeee.fffffffffff.gggggggggggggggg
for cccc in ddd.specification)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB25136704(self):
code = textwrap.dedent("""\
@@ -1442,16 +1442,16 @@ class _():
'xxxxxx': 'yyyyyy'
}] = cccccc.ddd('1m', '10x1+1')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB25165602(self):
code = textwrap.dedent("""\
def f():
ids = {u: i for u, i in zip(self.aaaaa, xrange(42, 42 + len(self.aaaaaa)))}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB25157123(self):
code = textwrap.dedent("""\
@@ -1459,8 +1459,8 @@ class _():
FairlyLongMethodName([relatively_long_identifier_for_a_list],
another_argument_with_a_long_identifier)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB25136820(self):
unformatted_code = textwrap.dedent("""\
@@ -1479,8 +1479,8 @@ class _():
'$bbbbbbbbbbbbbbbbbbbbbbbb',
})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB25131481(self):
unformatted_code = textwrap.dedent("""\
@@ -1499,8 +1499,8 @@ class _():
lambda x: x # do nothing
})
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB23445244(self):
unformatted_code = textwrap.dedent("""\
@@ -1526,8 +1526,8 @@ class _():
FLAGS.aaaaaaaaaaaaaa + FLAGS.bbbbbbbbbbbbbbbbbbb,
})
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB20559654(self):
unformatted_code = textwrap.dedent("""\
@@ -1547,8 +1547,8 @@ class _():
aaaaaaaaaaa=True,
bbbbbbbb=None)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB23943842(self):
unformatted_code = textwrap.dedent("""\
@@ -1585,8 +1585,8 @@ class _():
}
})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB20551180(self):
unformatted_code = textwrap.dedent("""\
@@ -1600,8 +1600,8 @@ class _():
return (struct.pack('aaaa', bbbbbbbbbb, ccccccccccccccc, dddddddd) +
eeeeeee)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB23944849(self):
unformatted_code = textwrap.dedent("""\
@@ -1620,8 +1620,8 @@ class _():
fffffffffffffff=0):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB23935890(self):
unformatted_code = textwrap.dedent("""\
@@ -1636,8 +1636,8 @@ class _():
eeeeeeeeeeeeeee):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB28414371(self):
code = textwrap.dedent("""\
@@ -1661,8 +1661,8 @@ class _():
| m.jjjj()
| m.ppppp(m.vvv[0] + m.vvv[1]))
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB20127686(self):
code = textwrap.dedent("""\
@@ -1679,8 +1679,8 @@ class _():
| m.jjjj()
| m.ppppp(m.VAL[0] / m.VAL[1]))
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB20016122(self):
unformatted_code = textwrap.dedent("""\
@@ -1697,9 +1697,9 @@ class _():
style.CreateStyleFromConfig(
'{based_on_style: pep8, split_penalty_import_names: 350}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -1726,8 +1726,8 @@ class _():
style.CreateStyleFromConfig('{based_on_style: yapf, '
'split_before_logical_operator: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -1743,8 +1743,8 @@ class _():
aaaaaa.bbbbbbbbbbbbbbbbbbbb[-1].cccccccccccccc.ddd().eeeeeeee(
ffffffffffffff)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB20849933(self):
unformatted_code = textwrap.dedent("""\
@@ -1763,8 +1763,8 @@ class _():
'%s/cccccc/ddddddddddddddddddd.jar' % (eeeeee.FFFFFFFFFFFFFFFFFF),
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB20813997(self):
code = textwrap.dedent("""\
@@ -1772,8 +1772,8 @@ class _():
myarray = numpy.zeros((2, 2, 2))
print(myarray[:, 1, :])
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB20605036(self):
code = textwrap.dedent("""\
@@ -1786,8 +1786,8 @@ class _():
}
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB20562732(self):
code = textwrap.dedent("""\
@@ -1798,8 +1798,8 @@ class _():
'Second item',
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB20128830(self):
code = textwrap.dedent("""\
@@ -1818,8 +1818,8 @@ class _():
},
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB20073838(self):
code = textwrap.dedent("""\
@@ -1835,8 +1835,8 @@ class _():
class_1_name=self.class_1_name,
class_1_count=class_1_count))
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB19626808(self):
code = textwrap.dedent("""\
@@ -1844,8 +1844,8 @@ class _():
aaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbb(
'ccccccccccc', ddddddddd='eeeee').fffffffff([ggggggggggggggggggggg])
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB19547210(self):
code = textwrap.dedent("""\
@@ -1858,8 +1858,8 @@ class _():
xxxxxxxxxxxx.yyyyyyyyyyyyyy.zzzzzzzz):
continue
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB19377034(self):
code = textwrap.dedent("""\
@@ -1868,8 +1868,8 @@ class _():
bbbbbbbbbbbbbbb.start >= bbbbbbbbbbbbbbb.end):
return False
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB19372573(self):
code = textwrap.dedent("""\
@@ -1884,8 +1884,8 @@ class _():
try:
style.SetGlobalStyle(style.CreatePEP8Style())
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreateYapfStyle())
@@ -1894,8 +1894,8 @@ class _():
a = {1, 2, 3}[x]
b = {'foo': 42, 'bar': 37}['foo']
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB19287512(self):
unformatted_code = textwrap.dedent("""\
@@ -1919,8 +1919,8 @@ class _():
-1, 'permission error'))):
self.assertRaises(nnnnnnnnnnnnnnnn.ooooo, ppppp.qqqqqqqqqqqqqqqqq)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB19194420(self):
code = textwrap.dedent("""\
@@ -1928,8 +1928,8 @@ class _():
'long argument goes here that causes the line to break',
lambda arg2=0.5: arg2)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB19073499(self):
code = """\
@@ -1940,8 +1940,8 @@ instance = (
'fnord': 6
}))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB18257115(self):
code = textwrap.dedent("""\
@@ -1950,8 +1950,8 @@ instance = (
self._Test(aaaa, bbbbbbb.cccccccccc, dddddddd, eeeeeeeeeee,
[ffff, ggggggggggg, hhhhhhhhhhhh, iiiiii, jjjj])
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB18256666(self):
code = textwrap.dedent("""\
@@ -1968,8 +1968,8 @@ instance = (
},
llllllllll=mmmmmm.nnnnnnnnnnnnnnnn)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB18256826(self):
code = textwrap.dedent("""\
@@ -1987,8 +1987,8 @@ instance = (
elif False:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB18255697(self):
code = textwrap.dedent("""\
@@ -1998,8 +1998,8 @@ instance = (
'YYYYYYYYYYYYYYYY': ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'],
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testB17534869(self):
unformatted_code = textwrap.dedent("""\
@@ -2012,8 +2012,8 @@ instance = (
self.assertLess(
abs(time.time() - aaaa.bbbbbbbbbbb(datetime.datetime.now())), 1)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB17489866(self):
unformatted_code = textwrap.dedent("""\
@@ -2030,8 +2030,8 @@ instance = (
return aaaa.bbbbbbbbb(
ccccccc=dddddddddddddd({('eeee', 'ffffffff'): str(j)}))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB17133019(self):
unformatted_code = textwrap.dedent("""\
@@ -2055,8 +2055,8 @@ instance = (
"eeeeeeeee ffffffffff"), "rb") as gggggggggggggggggggg:
print(gggggggggggggggggggg)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB17011869(self):
unformatted_code = textwrap.dedent("""\
@@ -2082,8 +2082,8 @@ instance = (
'DDDDDDDD': 0.4811
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB16783631(self):
unformatted_code = textwrap.dedent("""\
@@ -2099,8 +2099,8 @@ instance = (
ddddddddddddd, eeeeeeeee=self.fffffffffffff) as gggg:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB16572361(self):
unformatted_code = textwrap.dedent("""\
@@ -2116,8 +2116,8 @@ instance = (
'foo-bar-baz-biz-boo-baa-baa'].IncrementBy.assert_called_once_with(
'foo_bar_baz_boo')
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB15884241(self):
unformatted_code = textwrap.dedent("""\
@@ -2140,8 +2140,8 @@ instance = (
ffffffff=[s.strip() for s in bbb[5].split(",")],
gggggg=bbb[6])
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB15697268(self):
unformatted_code = textwrap.dedent("""\
@@ -2165,8 +2165,8 @@ instance = (
bad_slice = ("I am a crazy, no good, string what's too long, etc." +
" no really ")[:ARBITRARY_CONSTANT_A]
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB15597568(self):
unformatted_code = """\
@@ -2183,8 +2183,8 @@ if True:
(", and the process timed out." if did_time_out else ".")) %
errorcode)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB15542157(self):
unformatted_code = textwrap.dedent("""\
@@ -2194,8 +2194,8 @@ if True:
aaaaaaaaaaaa = bbbb.ccccccccccccccc(dddddd.eeeeeeeeeeeeee, ffffffffffffffffff,
gggggg.hhhhhhhhhhhhhhhhh)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB15438132(self):
unformatted_code = textwrap.dedent("""\
@@ -2229,8 +2229,8 @@ if True:
gggggg.hh, iiiiiiiiiiiiiiiiiii.jjjjjjjjjj.kkkkkkk, lllll.mm),
nnnnnnnnnn=ooooooo.pppppppppp)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB14468247(self):
unformatted_code = """\
@@ -2244,8 +2244,8 @@ call(
b=2,
)
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB14406499(self):
unformatted_code = textwrap.dedent("""\
@@ -2257,8 +2257,8 @@ parameter_5, parameter_6): pass
parameter_6):
pass
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB13900309(self):
unformatted_code = textwrap.dedent("""\
@@ -2269,8 +2269,8 @@ parameter_5, parameter_6): pass
self.aaaaaaaaaaa( # A comment in the middle of it all.
948.0 / 3600, self.bbb.ccccccccccccccccccccc(dddddddddddddddd.eeee, True))
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
code = textwrap.dedent("""\
aaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbb.cccccccccccccccccccccccccccccc(
@@ -2278,8 +2278,8 @@ parameter_5, parameter_6): pass
CCCCCCC).ddddddddd( # Look! A comment is here.
AAAAAAAA - (20 * 60 - 5))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
aaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccccccccccccccccccccc().dddddddddddddddddddddddddd(1, 2, 3, 4)
@@ -2288,8 +2288,8 @@ parameter_5, parameter_6): pass
aaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccccccccccccccccccccc(
).dddddddddddddddddddddddddd(1, 2, 3, 4)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
aaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccccccccccccccccccccc(x).dddddddddddddddddddddddddd(1, 2, 3, 4)
@@ -2298,8 +2298,8 @@ parameter_5, parameter_6): pass
aaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccccccccccccccccccccc(
x).dddddddddddddddddddddddddd(1, 2, 3, 4)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
aaaaaaaaaaaaaaaaaaaaaaaa(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).dddddddddddddddddddddddddd(1, 2, 3, 4)
@@ -2308,8 +2308,8 @@ parameter_5, parameter_6): pass
aaaaaaaaaaaaaaaaaaaaaaaa(
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).dddddddddddddddddddddddddd(1, 2, 3, 4)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
aaaaaaaaaaaaaaaaaaaaaaaa().bbbbbbbbbbbbbbbbbbbbbbbb().ccccccccccccccccccc().\
@@ -2320,8 +2320,8 @@ dddddddddddddddddd().eeeeeeeeeeeeeeeeeeeee().fffffffffffffffff().ggggggggggggggg
).dddddddddddddddddd().eeeeeeeeeeeeeeeeeeeee().fffffffffffffffff(
).gggggggggggggggggg()
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testB67935687(self):
code = textwrap.dedent("""\
@@ -2329,8 +2329,8 @@ dddddddddddddddddd().eeeeeeeeeeeeeeeeeeeee().fffffffffffffffff().ggggggggggggggg
Raw('monarch.BorgTask', '/union/row_operator_action_delay'),
{'borg_user': self.borg_user})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
shelf_renderer.expand_text = text.translate_to_unicode(
@@ -2342,8 +2342,8 @@ dddddddddddddddddd().eeeeeeeeeeeeeeeeeeeee().fffffffffffffffff().ggggggggggggggg
shelf_renderer.expand_text = text.translate_to_unicode(expand_text %
{'creator': creator})
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
if __name__ == '__main__':
diff --git a/yapftests/reformatter_facebook_test.py b/yapftests/reformatter_facebook_test.py
index 2e6b1d7..c61f32b 100644
--- a/yapftests/reformatter_facebook_test.py
+++ b/yapftests/reformatter_facebook_test.py
@@ -38,8 +38,8 @@ class TestsForFacebookStyle(yapf_test_helper.YAPFTest):
def overly_long_function_name(just_one_arg, **kwargs):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDedentClosingBracket(self):
unformatted_code = textwrap.dedent("""\
@@ -54,8 +54,8 @@ class TestsForFacebookStyle(yapf_test_helper.YAPFTest):
):
pass
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testBreakAfterOpeningBracketIfContentsTooBig(self):
unformatted_code = textwrap.dedent("""\
@@ -70,8 +70,8 @@ v, w, x, y, z
):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDedentClosingBracketWithComments(self):
unformatted_code = textwrap.dedent("""\
@@ -91,8 +91,8 @@ v, w, x, y, z
):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDedentImportAsNames(self):
code = textwrap.dedent("""\
@@ -103,8 +103,8 @@ v, w, x, y, z
SOME_CONSTANT_NUMBER3,
)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testDedentTestListGexp(self):
unformatted_code = textwrap.dedent("""\
@@ -141,8 +141,8 @@ v, w, x, y, z
) as exception:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testBrokenIdempotency(self):
# TODO(ambv): The following behaviour should be fixed.
@@ -160,8 +160,8 @@ v, w, x, y, z
) as exception:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(pass0_code)
- self.assertCodeEqual(pass1_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(pass0_code)
+ self.assertCodeEqual(pass1_code, reformatter.Reformat(llines))
pass2_code = textwrap.dedent("""\
try:
@@ -171,8 +171,8 @@ v, w, x, y, z
) as exception:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(pass1_code)
- self.assertCodeEqual(pass2_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(pass1_code)
+ self.assertCodeEqual(pass2_code, reformatter.Reformat(llines))
def testIfExprHangingIndent(self):
unformatted_code = textwrap.dedent("""\
@@ -194,8 +194,8 @@ v, w, x, y, z
):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSimpleDedenting(self):
unformatted_code = textwrap.dedent("""\
@@ -208,8 +208,8 @@ v, w, x, y, z
result.reason_not_added, "current preflight is still running"
)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDedentingWithSubscripts(self):
unformatted_code = textwrap.dedent("""\
@@ -231,8 +231,8 @@ v, w, x, y, z
clues_lists, effect, constraints[0], constraint_manager
)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDedentingCallsWithInnerLists(self):
code = textwrap.dedent("""\
@@ -242,8 +242,8 @@ v, w, x, y, z
'effect': Clue((cls.effect_time, 'apache_host'), effect_line, 40)
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testDedentingListComprehension(self):
unformatted_code = textwrap.dedent("""\
@@ -320,8 +320,8 @@ v, w, x, y, z
('localhost', os.path.join(path, 'node_2.log'), super_parser)
]
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testMustSplitDedenting(self):
code = textwrap.dedent("""\
@@ -332,8 +332,8 @@ v, w, x, y, z
LineSource('localhost', xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testDedentIfConditional(self):
code = textwrap.dedent("""\
@@ -346,8 +346,8 @@ v, w, x, y, z
):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testDedentSet(self):
code = textwrap.dedent("""\
@@ -362,8 +362,8 @@ v, w, x, y, z
]
)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testDedentingInnerScope(self):
code = textwrap.dedent("""\
@@ -375,12 +375,12 @@ v, w, x, y, z
constraints, InvestigationResult.OR
)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(code, reformatted_code)
- uwlines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(code, reformatted_code)
def testCommentWithNewlinesInPrefix(self):
@@ -409,8 +409,8 @@ v, w, x, y, z
print(foo())
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testIfStmtClosingBracket(self):
unformatted_code = """\
@@ -424,8 +424,8 @@ if (
):
return False
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
if __name__ == '__main__':
diff --git a/yapftests/reformatter_pep8_test.py b/yapftests/reformatter_pep8_test.py
index b07ae1e..acc218d 100644
--- a/yapftests/reformatter_pep8_test.py
+++ b/yapftests/reformatter_pep8_test.py
@@ -38,8 +38,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
if a + b:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSingleLineIfStatements(self):
code = textwrap.dedent("""\
@@ -47,8 +47,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
elif False: b = 42
else: c = 42
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testBlankBetweenClassAndDef(self):
unformatted_code = textwrap.dedent("""\
@@ -62,8 +62,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
def joe():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testBlankBetweenDefsInClass(self):
unformatted_code = textwrap.dedent('''\
@@ -87,8 +87,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
def is_running(self):
return self.running
''')
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSingleWhiteBeforeTrailingComment(self):
unformatted_code = textwrap.dedent("""\
@@ -99,8 +99,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
if a + b: # comment
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSpaceBetweenEndingCommandAndClosingBracket(self):
unformatted_code = textwrap.dedent("""\
@@ -111,8 +111,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
expected_formatted_code = textwrap.dedent("""\
a = (1, )
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testContinuedNonOutdentedLine(self):
code = textwrap.dedent("""\
@@ -121,8 +121,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
) != self.geom_type and not self.geom_type == 'GEOMETRY':
ror(code='om_type')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testWrappingPercentExpressions(self):
unformatted_code = textwrap.dedent("""\
@@ -145,8 +145,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
zzzzz = '%s-%s'.ww(xxxxxxxxxxxxxxxxxxxxxxx + 1,
xxxxxxxxxxxxxxxxxxxxx + 1)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testAlignClosingBracketWithVisualIndentation(self):
unformatted_code = textwrap.dedent("""\
@@ -161,8 +161,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
'baz' # second comment
)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
def f():
@@ -182,8 +182,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb'):
pass
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testIndentSizeChanging(self):
unformatted_code = textwrap.dedent("""\
@@ -195,8 +195,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
runtime_mins = (program_end_time -
program_start_time).total_seconds() / 60.0
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testHangingIndentCollision(self):
unformatted_code = textwrap.dedent("""\
@@ -234,8 +234,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
morestuff.andmore.andmore.andmore.andmore.andmore.andmore.andmore):
dosomething(connection)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplittingBeforeLogicalOperator(self):
try:
@@ -264,9 +264,9 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
or update.message.migrate_from_chat_id
or update.message.pinned_message)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -282,8 +282,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
keys.append(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) # may be unassigned.
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplittingBeforeFirstArgument(self):
try:
@@ -301,9 +301,9 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
long_argument_name_3=3,
long_argument_name_4=4)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -317,8 +317,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
df = df[(df['campaign_status'] == 'LIVE')
& (df['action_status'] == 'LIVE')]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplitListsAndDictSetMakersIfCommaTerminated(self):
unformatted_code = textwrap.dedent("""\
@@ -337,8 +337,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
"context_processors",
]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplitAroundNamedAssigns(self):
unformatted_code = textwrap.dedent("""\
@@ -355,8 +355,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
aaaaaaaaaa=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testUnaryOperator(self):
unformatted_code = textwrap.dedent("""\
@@ -371,8 +371,8 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
if -3 < x < 3:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNoSplitBeforeDictValue(self):
try:
@@ -400,9 +400,9 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
),
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
X = {'a': 1, 'b': 2, 'key': this_is_a_function_call_that_goes_over_the_column_limit_im_pretty_sure()}
@@ -414,9 +414,9 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
'key': this_is_a_function_call_that_goes_over_the_column_limit_im_pretty_sure()
}
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
attrs = {
@@ -436,9 +436,9 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
),
}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
unformatted_code = textwrap.dedent("""\
css_class = forms.CharField(
@@ -456,9 +456,9 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest):
),
)
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -482,8 +482,8 @@ def _():
& (cdffile['Latitude'][:] >= select_lat - radius)
& (cdffile['Latitude'][:] <= select_lat + radius))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertEqual(expected_code, reformatter.Reformat(llines))
def testNoBlankLinesOnlyForFirstNestedObject(self):
unformatted_code = '''\
@@ -516,8 +516,8 @@ class Demo:
bar docs
"""
'''
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertEqual(expected_code, reformatter.Reformat(llines))
def testSplitBeforeArithmeticOperators(self):
try:
@@ -534,9 +534,9 @@ def _():
raise ValueError('This is a long message that ends with an argument: '
+ str(42))
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -551,8 +551,8 @@ foo([(1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1),
(1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 10), (1, 11), (1, 10),
(1, 11), (10, 11)])
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_code, reformatter.Reformat(llines))
def testNoBlankLineBeforeNestedFuncOrClass(self):
try:
@@ -589,9 +589,9 @@ def normal_function():
return nested_function
'''
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -620,8 +620,8 @@ class _():
self._cs = charset
self._preprocess = preprocess
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testParamListIndentationCollision2(self):
code = textwrap.dedent("""\
@@ -629,8 +629,8 @@ class _():
argument0, argument1):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testParamListIndentationCollision3(self):
code = textwrap.dedent("""\
@@ -647,8 +647,8 @@ class _():
):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testTwoWordComparisonOperators(self):
unformatted_code = textwrap.dedent("""\
@@ -661,8 +661,8 @@ class _():
_ = (klsdfjdklsfjksdlfjdklsfjdslkfjsdkl
not in {ksldfjsdklfjdklsfjdklsfjdklsfjdsklfjdklsfj})
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
@unittest.skipUnless(not py3compat.PY3, 'Requires Python 2.7')
def testAsyncAsNonKeyword(self):
@@ -679,8 +679,8 @@ class _():
def bar(self):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines, verify=False))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines, verify=False))
def testStableInlinedDictionaryFormatting(self):
unformatted_code = textwrap.dedent("""\
@@ -697,12 +697,12 @@ class _():
}))
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(expected_formatted_code, reformatted_code)
- uwlines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
- reformatted_code = reformatter.Reformat(uwlines)
+ llines = yapf_test_helper.ParseAndUnwrap(reformatted_code)
+ reformatted_code = reformatter.Reformat(llines)
self.assertCodeEqual(expected_formatted_code, reformatted_code)
@unittest.skipUnless(py3compat.PY36, 'Requires Python 3.6')
@@ -713,8 +713,8 @@ class _():
place: ...
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines, verify=False))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines, verify=False))
@unittest.skipUnless(py3compat.PY36, 'Requires Python 3.6')
def testSpaceBetweenDictColonAndElipses(self):
@@ -726,8 +726,8 @@ class _():
{0: "...", 1: ...}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
class TestsForSpacesInsideBrackets(yapf_test_helper.YAPFTest):
@@ -797,8 +797,8 @@ class TestsForSpacesInsideBrackets(yapf_test_helper.YAPFTest):
string_idx = "mystring"[ 3 ]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDefault(self):
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -835,8 +835,8 @@ class TestsForSpacesInsideBrackets(yapf_test_helper.YAPFTest):
string_idx = "mystring"[3]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
@unittest.skipUnless(py3compat.PY36, 'Requires Python 3.6')
def testAwait(self):
@@ -870,8 +870,8 @@ class TestsForSpacesInsideBrackets(yapf_test_helper.YAPFTest):
if ( await get_html() ):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
class TestsForSpacesAroundSubscriptColon(yapf_test_helper.YAPFTest):
@@ -904,8 +904,8 @@ class TestsForSpacesAroundSubscriptColon(yapf_test_helper.YAPFTest):
d1 = list4[1 : 20 :]
e1 = list5[1 : 20 : 3]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testWithSpaceInsideBrackets(self):
style.SetGlobalStyle(
@@ -925,8 +925,8 @@ class TestsForSpacesAroundSubscriptColon(yapf_test_helper.YAPFTest):
d1 = list4[ 1 : 20 : ]
e1 = list5[ 1 : 20 : 3 ]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testDefault(self):
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -942,8 +942,8 @@ class TestsForSpacesAroundSubscriptColon(yapf_test_helper.YAPFTest):
d1 = list4[1:20:]
e1 = list5[1:20:3]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(self.unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
if __name__ == '__main__':
diff --git a/yapftests/reformatter_python3_test.py b/yapftests/reformatter_python3_test.py
index dbf3930..b5d68e8 100644
--- a/yapftests/reformatter_python3_test.py
+++ b/yapftests/reformatter_python3_test.py
@@ -44,8 +44,8 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
eeeeeeeeeeeeee: set = {1, 2, 3}) -> bool:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testTypedNameWithLongNamedArg(self):
unformatted_code = textwrap.dedent("""\
@@ -57,8 +57,8 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
) -> ReturnType:
pass
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testKeywordOnlyArgSpecifier(self):
unformatted_code = textwrap.dedent("""\
@@ -69,8 +69,8 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
def foo(a, *, kw):
return a + kw
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
@unittest.skipUnless(py3compat.PY36, 'Requires Python 3.6')
def testPEP448ParameterExpansion(self):
@@ -86,8 +86,8 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
{**{**x}, **x}
{'a': 1, **kw, 'b': 3, **kw2}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testAnnotations(self):
unformatted_code = textwrap.dedent("""\
@@ -98,14 +98,14 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
def foo(a: list, b: "bar") -> dict:
return a + b
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testExecAsNonKeyword(self):
unformatted_code = 'methods.exec( sys.modules[name])\n'
expected_formatted_code = 'methods.exec(sys.modules[name])\n'
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testAsyncFunctions(self):
if sys.version_info[1] < 5:
@@ -126,8 +126,8 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
if (await get_html()):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines, verify=False))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines, verify=False))
def testNoSpacesAroundPowerOperator(self):
unformatted_code = textwrap.dedent("""\
@@ -142,9 +142,9 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
style.CreateStyleFromConfig(
'{based_on_style: pep8, SPACES_AROUND_POWER_OPERATOR: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -162,9 +162,9 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
'{based_on_style: pep8, '
'SPACES_AROUND_DEFAULT_OR_NAMED_ASSIGN: True}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -185,8 +185,8 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
def foo2(x: 'int' = 42):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testMatrixMultiplication(self):
unformatted_code = textwrap.dedent("""\
@@ -195,15 +195,15 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest):
expected_formatted_code = textwrap.dedent("""\
a = b @ c
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testNoneKeyword(self):
code = """\
None.__ne__()
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testAsyncWithPrecedingComment(self):
if sys.version_info[1] < 5:
@@ -230,8 +230,8 @@ None.__ne__()
async def foo():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testAsyncFunctionsNested(self):
if sys.version_info[1] < 5:
@@ -242,8 +242,8 @@ None.__ne__()
async def inner():
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testKeepTypesIntact(self):
if sys.version_info[1] < 5:
@@ -260,8 +260,8 @@ None.__ne__()
) -> List[automation_converter.PyiCollectionAbc]:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testContinuationIndentWithAsync(self):
if sys.version_info[1] < 5:
@@ -278,8 +278,8 @@ None.__ne__()
r"ws://a_really_long_long_long_long_long_long_url") as ws:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testSplittingArguments(self):
if sys.version_info[1] < 5:
@@ -345,9 +345,9 @@ def run_sync_in_worker_thread(sync_fn, *args, cancellable=False, limiter=None):
'split_arguments_when_comma_terminated: true, '
'split_before_first_argument: true}'))
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
@@ -373,8 +373,8 @@ class Foo:
**foofoofoo
})
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testMultilineFormatString(self):
if sys.version_info[1] < 6:
@@ -386,8 +386,8 @@ class Foo:
# yapf: enable
"""
# https://github.com/google/yapf/issues/513
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testEllipses(self):
if sys.version_info[1] < 6:
@@ -397,8 +397,8 @@ def dirichlet(x12345678901234567890123456789012345678901234567890=...) -> None:
return
"""
# https://github.com/google/yapf/issues/533
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testFunctionTypedReturnNextLine(self):
code = """\
@@ -408,8 +408,8 @@ def _GenerateStatsEntries(
) -> Sequence[ssssssssssss.SSSSSSSSSSSSSSS]:
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testFunctionTypedReturnSameLine(self):
code = """\
@@ -417,8 +417,8 @@ def rrrrrrrrrrrrrrrrrrrrrr(
ccccccccccccccccccccccc: Tuple[Text, Text]) -> List[Tuple[Text, Text]]:
pass
"""
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testAsyncForElseNotIndentedInsideBody(self):
if sys.version_info[1] < 5:
@@ -433,8 +433,8 @@ def rrrrrrrrrrrrrrrrrrrrrr(
else:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testForElseInAsyncNotMixedWithAsyncFor(self):
if sys.version_info[1] < 5:
@@ -446,8 +446,8 @@ def rrrrrrrrrrrrrrrrrrrrrr(
else:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines))
def testParameterListIndentationConflicts(self):
unformatted_code = textwrap.dedent("""\
@@ -465,8 +465,8 @@ def rrrrrrrrrrrrrrrrrrrrrr(
forward_from=None):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
if __name__ == '__main__':
diff --git a/yapftests/reformatter_style_config_test.py b/yapftests/reformatter_style_config_test.py
index 9c258ca..c5726cb 100644
--- a/yapftests/reformatter_style_config_test.py
+++ b/yapftests/reformatter_style_config_test.py
@@ -38,9 +38,9 @@ class TestsForStyleConfig(yapf_test_helper.YAPFTest):
for i in range(5):
print('bar')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
style.DEFAULT_STYLE = self.current_style
@@ -53,8 +53,8 @@ class TestsForStyleConfig(yapf_test_helper.YAPFTest):
for i in range(5):
print('bar')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
- self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def testOperatorNoSpaceStyle(self):
try:
@@ -71,9 +71,9 @@ class TestsForStyleConfig(yapf_test_helper.YAPFTest):
b = '0'*1
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
style.DEFAULT_STYLE = self.current_style
@@ -114,9 +114,9 @@ class TestsForStyleConfig(yapf_test_helper.YAPFTest):
k = (1*2*3) + (4*5*6*7*8)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines))
+ reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
style.DEFAULT_STYLE = self.current_style
@@ -156,8 +156,8 @@ class TestsForStyleConfig(yapf_test_helper.YAPFTest):
plt.plot(veryverylongvariablename, veryverylongvariablename, marker="x",
color="r")
""") # noqa
- uwlines = yapf_test_helper.ParseAndUnwrap(formatted_code)
- self.assertCodeEqual(formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(formatted_code)
+ self.assertCodeEqual(formatted_code, reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
style.DEFAULT_STYLE = self.current_style
@@ -187,8 +187,8 @@ class TestsForStyleConfig(yapf_test_helper.YAPFTest):
marker="x",
color="r")
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(formatted_code)
- self.assertCodeEqual(formatted_code, reformatter.Reformat(uwlines))
+ llines = yapf_test_helper.ParseAndUnwrap(formatted_code)
+ self.assertCodeEqual(formatted_code, reformatter.Reformat(llines))
finally:
style.SetGlobalStyle(style.CreatePEP8Style())
style.DEFAULT_STYLE = self.current_style
diff --git a/yapftests/reformatter_verify_test.py b/yapftests/reformatter_verify_test.py
index c10cb86..33ba3a6 100644
--- a/yapftests/reformatter_verify_test.py
+++ b/yapftests/reformatter_verify_test.py
@@ -36,10 +36,10 @@ class TestVerifyNoVerify(yapf_test_helper.YAPFTest):
class ABC(metaclass=type):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
with self.assertRaises(verifier.InternalError):
- reformatter.Reformat(uwlines, verify=True)
- reformatter.Reformat(uwlines) # verify should be False by default.
+ reformatter.Reformat(llines, verify=True)
+ reformatter.Reformat(llines) # verify should be False by default.
def testNoVerify(self):
unformatted_code = textwrap.dedent("""\
@@ -50,9 +50,9 @@ class TestVerifyNoVerify(yapf_test_helper.YAPFTest):
class ABC(metaclass=type):
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines, verify=False))
+ reformatter.Reformat(llines, verify=False))
def testVerifyFutureImport(self):
unformatted_code = textwrap.dedent("""\
@@ -64,9 +64,9 @@ class TestVerifyNoVerify(yapf_test_helper.YAPFTest):
if __name__ == "__main__":
call_my_function(print)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
with self.assertRaises(verifier.InternalError):
- reformatter.Reformat(uwlines, verify=True)
+ reformatter.Reformat(llines, verify=True)
expected_formatted_code = textwrap.dedent("""\
from __future__ import print_function
@@ -79,9 +79,9 @@ class TestVerifyNoVerify(yapf_test_helper.YAPFTest):
if __name__ == "__main__":
call_my_function(print)
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
- reformatter.Reformat(uwlines, verify=False))
+ reformatter.Reformat(llines, verify=False))
def testContinuationLineShouldBeDistinguished(self):
code = textwrap.dedent("""\
@@ -92,8 +92,8 @@ class TestVerifyNoVerify(yapf_test_helper.YAPFTest):
self.generators + self.next_batch) == 1:
pass
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self.assertCodeEqual(code, reformatter.Reformat(uwlines, verify=False))
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(llines, verify=False))
if __name__ == '__main__':
diff --git a/yapftests/subtype_assigner_test.py b/yapftests/subtype_assigner_test.py
index 66be68e..7651061 100644
--- a/yapftests/subtype_assigner_test.py
+++ b/yapftests/subtype_assigner_test.py
@@ -25,18 +25,18 @@ from yapftests import yapf_test_helper
class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
- def _CheckFormatTokenSubtypes(self, uwlines, list_of_expected):
- """Check that the tokens in the UnwrappedLines have the expected subtypes.
+ def _CheckFormatTokenSubtypes(self, llines, list_of_expected):
+ """Check that the tokens in the LogicalLines have the expected subtypes.
Args:
- uwlines: list of UnwrappedLine.
+ llines: list of LogicalLine.
list_of_expected: list of (name, subtype) pairs. Non-semantic tokens are
filtered out from the expected values.
"""
actual = []
- for uwl in uwlines:
+ for lline in llines:
filtered_values = [(ft.value, ft.subtypes)
- for ft in uwl.tokens
+ for ft in lline.tokens
if ft.name not in pytree_utils.NONSEMANTIC_TOKENS]
if filtered_values:
actual.append(filtered_values)
@@ -49,8 +49,8 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
def foo(a=37, *b, **c):
return -x[:42]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckFormatTokenSubtypes(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckFormatTokenSubtypes(llines, [
[
('def', {subtypes.NONE}),
('foo', {subtypes.FUNC_DEF}),
@@ -109,8 +109,8 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
code = textwrap.dedent(r"""
foo(x, a='hello world')
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckFormatTokenSubtypes(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckFormatTokenSubtypes(llines, [
[
('foo', {subtypes.NONE}),
('(', {subtypes.NONE}),
@@ -134,8 +134,8 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
def foo(strs):
return {s.lower() for s in strs}
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckFormatTokenSubtypes(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckFormatTokenSubtypes(llines, [
[
('def', {subtypes.NONE}),
('foo', {subtypes.FUNC_DEF}),
@@ -171,8 +171,8 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
code = textwrap.dedent("""\
not a
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckFormatTokenSubtypes(uwlines,
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckFormatTokenSubtypes(llines,
[[('not', {subtypes.UNARY_OPERATOR}),
('a', {subtypes.NONE})]])
@@ -180,8 +180,8 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
code = textwrap.dedent("""\
x = ((a | (b ^ 3) & c) << 3) >> 1
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckFormatTokenSubtypes(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckFormatTokenSubtypes(llines, [
[
('x', {subtypes.NONE}),
('=', {subtypes.ASSIGN_OPERATOR}),
@@ -209,8 +209,8 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
code = textwrap.dedent("""\
x = ((a + (b - 3) * (1 % c) @ d) / 3) // 1
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckFormatTokenSubtypes(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckFormatTokenSubtypes(llines, [
[
('x', {subtypes.NONE}),
('=', {subtypes.ASSIGN_OPERATOR}),
@@ -250,8 +250,8 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
code = textwrap.dedent("""\
x[0:42:1]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckFormatTokenSubtypes(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckFormatTokenSubtypes(llines, [
[
('x', {subtypes.NONE}),
('[', {subtypes.SUBSCRIPT_BRACKET}),
@@ -268,8 +268,8 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
code = textwrap.dedent("""\
[a, *b]
""")
- uwlines = yapf_test_helper.ParseAndUnwrap(code)
- self._CheckFormatTokenSubtypes(uwlines, [
+ llines = yapf_test_helper.ParseAndUnwrap(code)
+ self._CheckFormatTokenSubtypes(llines, [
[
('[', {subtypes.NONE}),
('a', {subtypes.NONE}),
diff --git a/yapftests/yapf_test_helper.py b/yapftests/yapf_test_helper.py
index df89b70..3d1da12 100644
--- a/yapftests/yapf_test_helper.py
+++ b/yapftests/yapf_test_helper.py
@@ -64,7 +64,7 @@ class YAPFTest(unittest.TestCase):
def ParseAndUnwrap(code, dumptree=False):
- """Produces unwrapped lines from the given code.
+ """Produces logical lines from the given code.
Parses the code into a tree, performs comment splicing and runs the
unwrapper.
@@ -75,7 +75,7 @@ def ParseAndUnwrap(code, dumptree=False):
to stderr. Useful for debugging.
Returns:
- List of unwrapped lines.
+ List of logical lines.
"""
tree = pytree_utils.ParseCodeToTree(code)
comment_splicer.SpliceComments(tree)
@@ -88,8 +88,8 @@ def ParseAndUnwrap(code, dumptree=False):
if dumptree:
pytree_visitor.DumpPyTree(tree, target_stream=sys.stderr)
- uwlines = pytree_unwrapper.UnwrapPyTree(tree)
- for uwl in uwlines:
- uwl.CalculateFormattingInformation()
+ llines = pytree_unwrapper.UnwrapPyTree(tree)
+ for lline in llines:
+ lline.CalculateFormattingInformation()
- return uwlines
+ return llines