Module Expr Str ImportFrom alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore ListLoad Assign NameStore NameLoad For NameStore Call NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Expr Call NameLoad NameLoad AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore BinOpMult Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If UnaryOpNot AttributeLoad NameLoad attr body If AttributeLoad AttributeLoad NameLoad attr attr body Assign AttributeStore AttributeLoad AttributeLoad NameLoad attr attr attr Call AttributeLoad AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr attr orelse If AttributeLoad AttributeLoad NameLoad attr attr body Assign AttributeStore AttributeLoad AttributeLoad NameLoad attr attr attr Call AttributeLoad AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr attr If BoolOpAnd NameLoad AttributeLoad NameLoad attr body Expr Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr If Call NameLoad GeneratorExp AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr body Expr Call NameLoad NameLoad If BoolOpOr Call NameLoad NameLoad AttributeLoad NameLoad attr Call NameLoad NameLoad body Expr Call NameLoad NameLoad Expr Call NameLoad NameLoad NameLoad Expr Call NameLoad NameLoad orelse If Call NameLoad NameLoad body While AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad orelse If UnaryOpNot Call NameLoad NameLoad keyword NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call NameLoad NameLoad Expr Call NameLoad NameLoad NameLoad Expr Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad Assign NameStore ListLoad For NameStore NameLoad body Assign NameStore ListLoad For NameStore AttributeLoad NameLoad attr body If UnaryOpNot AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse If BoolOpAnd UnaryOpNot Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Str UnaryOpNot Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Str body If BoolOpOr CompareEq AttributeLoad AttributeLoad NameLoad attr attr Str CompareNotIn AttributeLoad AttributeLoad NameLoad attr attr Str body Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Return BinOpAdd Call AttributeLoad Str attr NameLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore NameLoad If CompareIsNot NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr For NameStore AttributeLoad NameLoad attr body Expr Call NameLoad NameLoad NameLoad Assign NameStore NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareIs NameLoad NameLoad body Return If AttributeLoad NameLoad attr body Assign NameStore BinOpAdd AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Str orelse If AttributeLoad NameLoad attr body Assign NameStore AttributeLoad AttributeLoad NameLoad attr attr orelse Assign NameStore AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign NameStore BinOpSub AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Str orelse Assign NameStore AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpSub NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore NameLoad For NameStore AttributeLoad NameLoad attr body If BoolOpAnd AttributeLoad NameLoad attr NameLoad body If CompareGt BinOpSub BinOpSub AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Str AttributeLoad NameLoad attr Num body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore NameLoad While AttributeLoad NameLoad attr body Assign NameStore AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body AugAssignAdd NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str If AttributeLoad NameLoad attr body Assign NameStore NameLoad orelse Assign NameStore BoolOpAnd CompareIsNot NameLoad NameLoad CompareGt AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If Call AttributeLoad NameLoad attr Str body For NameStore AttributeLoad NameLoad attr body If BoolOpAnd AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr body Return NameLoad If Call AttributeLoad NameLoad attr Str body Assign NameStore Call NameLoad AttributeLoad NameLoad attr Assign NameStore Num While CompareLt NameLoad BinOpSub NameLoad Num body If BoolOpAnd CompareEq AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index BinOpAdd NameLoad Num attr Str CompareIn AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr Call AttributeLoad NameLoad attr Str body Return NameLoad AugAssignAdd NameStore Num Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad GeneratorExp AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore BinOpMult Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Return BoolOpAnd CompareLtE BinOpAdd AttributeLoad AttributeLoad NameLoad attr attr NameLoad Call AttributeLoad NameLoad attr Str UnaryOpNot Call NameLoad GeneratorExp AttributeLoad NameLoad attr comprehension NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Num decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return Call AttributeLoad Str attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list Assign NameStore Call AttributeLoad NameLoad attr Str ListLoad Str Str Assign NameStore Call AttributeLoad NameLoad attr Str ListLoad Str Str FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Num Assign NameStore Call NameLoad Assign NameStore ListLoad Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Call NameLoad Call NameLoad Num NameLoad NameLoad AugAssignAdd NameStore Num Assign NameStore Num While NameLoad body Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore AttributeLoad NameLoad attr If UnaryOpNot AttributeLoad AttributeLoad NameLoad attr attr body Break Expr Call AttributeLoad NameLoad attr NameLoad If CompareGt NameLoad Num body Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad If CompareIn AttributeLoad NameLoad attr NameLoad body Continue Assert CompareGtE NameLoad NameLoad Assign NameStore NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad If UnaryOpNot NameLoad body Return NameLoad If UnaryOpNot NameLoad body Expr Call NameLoad NameLoad AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If BoolOpAnd NameLoad UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr body Return NameLoad If BoolOpAnd UnaryOpNot NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr body Return NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad AugAssignAdd NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Call NameLoad Call NameLoad NameLoad NameLoad NameLoad Return BinOpAdd NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr While AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore AttributeLoad NameLoad attr For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad NameLoad NameLoad keyword NameLoad decorator_list Assign NameStore Num Assign NameStore Num Assign NameStore Num FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str If CompareIs NameLoad NameLoad body If CompareIsNot AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad Return Num If AttributeLoad NameLoad attr body Return NameLoad Assign NameStore AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body If BoolOpAnd UnaryOpNot NameLoad CompareIn AttributeLoad NameLoad attr Set Str Str Str body Return NameLoad If Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad body Return NameLoad orelse Return NameLoad If CompareIn AttributeLoad NameLoad attr Set Str Str Str body If UnaryOpNot NameLoad body Assign NameStore CompareEq Call AttributeLoad AttributeLoad NameLoad attr attr Str Num If BoolOpAnd AttributeLoad NameLoad attr UnaryOpNot NameLoad body If Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad body Assign NameStore BinOpSub Call NameLoad NameLoad Num While CompareGt NameLoad Num body If UnaryOpNot AttributeLoad SubscriptLoad NameLoad Index BinOpSub NameLoad Num attr body Break AugAssignSub NameStore Num If CompareEq AttributeLoad AttributeLoad SubscriptLoad NameLoad Index BinOpSub NameLoad Num attr attr Str body Expr Call AttributeLoad AttributeLoad SubscriptLoad NameLoad Index NameLoad attr attr NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad If CompareIsNot AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad Return NameLoad orelse If CompareIn AttributeLoad AttributeLoad NameLoad attr attr Set Str Str body If UnaryOpNot Call AttributeLoad NameLoad attr Str body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad Return NameLoad If AttributeLoad NameLoad attr body Assign NameStore BinOpSub AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Str orelse Assign NameStore AttributeLoad NameLoad attr If CompareGt BinOpSub NameLoad AttributeLoad NameLoad attr Num body Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Num Assign NameStore NameLoad While CompareLt NameLoad Call NameLoad NameLoad body If AttributeLoad SubscriptLoad NameLoad Index NameLoad attr body Assign NameStore SubscriptLoad NameLoad Index NameLoad AugAssignAdd NameStore Num While CompareLt NameLoad Call NameLoad NameLoad body Assign NameStore BinOpAdd AttributeLoad AttributeLoad NameLoad attr attr Num If CompareNotEq AttributeLoad SubscriptLoad NameLoad Index NameLoad attr AttributeLoad NameLoad attr body Break If CompareNotEq AttributeLoad AttributeLoad NameLoad attr attr Str body Assign NameStore Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword Str keyword TupleLoad Str TupleLoad AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad For NameStore AttributeLoad SubscriptLoad NameLoad Index NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Num Expr Yield NameLoad orelse If Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index BinOpAdd NameLoad Num For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr NameLoad If BoolOpAnd CompareEq Call NameLoad AttributeLoad NameLoad attr Num AttributeLoad AttributeLoad NameLoad attr attr body Assign AttributeStore SubscriptLoad NameLoad Index NameLoad attr NameLoad Expr Yield SubscriptLoad NameLoad Index NameLoad AugAssignAdd NameStore Num Assign NameStore NameLoad orelse Expr Yield SubscriptLoad NameLoad Index NameLoad AugAssignAdd NameStore Num Assign NameStore NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body AugAssignSub NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Assign NameStore IfExp UnaryOpNot AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str Num Return CompareEq BinOpAdd AttributeLoad NameLoad attr NameLoad BinOpSub NameLoad Num decorator_list
N/A N/A 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.

  Reformat(): the main function exported by this module.
 __future__ unicode_literals N/A collections N/A heapq N/A re lib2to3 pytree lib2to3.pgen2 token yapf.yapflib format_decision_state yapf.yapflib format_token yapf.yapflib line_joiner yapf.yapflib pytree_utils yapf.yapflib style yapf.yapflib verifier Reformat N/A N/A uwlines verify N/A True N/A N/A Reformat the unwrapped lines.

  Arguments:
    uwlines: (list of unwrapped_line.UnwrappedLine) Lines we want to format.
    verify: (bool) True if reformatted code should be verified for syntax.

  Returns:
    A string representing the reformatted code.
   N/A final_lines N/A N/A prev_uwline None N/A uwline N/A _SingleOrMergedLines uwlines N/A N/A first_token N/A uwline first N/A N/A _FormatFirstToken first_token N/A uwline depth prev_uwline final_lines N/A indent_amt N/A N/A N/A style Get INDENT_WIDTH N/A uwline depth N/A state N/A N/A format_decision_state FormatDecisionState uwline indent_amt N/A N/A N/A uwline disable N/A N/A N/A N/A uwline first is_comment N/A N/A N/A N/A N/A uwline first node value N/A N/A N/A N/A N/A uwline first node value rstrip N/A N/A N/A N/A uwline last is_comment N/A N/A N/A N/A N/A uwline last node value N/A N/A N/A N/A N/A uwline last node value rstrip N/A N/A prev_uwline N/A prev_uwline disable N/A N/A N/A _RetainVerticalSpacingBetweenTokens N/A uwline first N/A prev_uwline last N/A N/A any N/A N/A tok is_comment N/A tok N/A uwline tokens N/A N/A N/A _RetainVerticalSpacingBeforeComments uwline N/A N/A N/A _LineContainsI18n uwline N/A uwline disable N/A _LineHasContinuationMarkers uwline N/A N/A N/A _RetainHorizontalSpacing uwline N/A N/A _RetainVerticalSpacing uwline prev_uwline N/A N/A _EmitLineUnformatted state N/A N/A N/A _CanPlaceOnSingleLine uwline N/A N/A N/A state next_token N/A N/A N/A N/A state AddTokenToState newline False dry_run False N/A N/A N/A N/A _AnalyzeSolutionSpace state dry_run False N/A N/A state N/A N/A format_decision_state FormatDecisionState uwline indent_amt N/A N/A _RetainHorizontalSpacing uwline N/A N/A _RetainVerticalSpacing uwline prev_uwline N/A N/A _EmitLineUnformatted state N/A N/A N/A final_lines append uwline N/A prev_uwline uwline N/A formatted_code N/A N/A line final_lines N/A N/A formatted_line N/A N/A tok N/A line tokens N/A N/A N/A N/A tok is_pseudo_paren N/A N/A N/A N/A formatted_line append N/A tok whitespace_prefix N/A N/A N/A formatted_line append N/A tok value N/A N/A N/A N/A N/A N/A N/A N/A tok next_token whitespace_prefix startswith N/A N/A N/A N/A N/A tok next_token whitespace_prefix startswith N/A N/A N/A N/A N/A N/A tok previous_token value : N/A N/A N/A tok next_token value ,}]) N/A N/A N/A N/A formatted_line append N/A N/A N/A formatted_code append N/A N/A join formatted_line N/A verify N/A N/A N/A N/A verifier VerifyCode N/A formatted_code N/A -1 N/A N/A N/A N/A join formatted_code N/A _RetainHorizontalSpacing N/A N/A uwline N/A N/A N/A Retain all horizontal spacing between tokens. N/A tok N/A uwline tokens N/A N/A N/A N/A tok RetainHorizontalSpacing N/A N/A uwline first column N/A uwline depth N/A _RetainVerticalSpacing N/A N/A cur_uwline prev_uwline N/A N/A N/A prev_tok None N/A N/A prev_uwline None N/A N/A prev_tok N/A prev_uwline last N/A cur_tok N/A cur_uwline tokens N/A N/A N/A _RetainVerticalSpacingBetweenTokens cur_tok prev_tok N/A prev_tok cur_tok N/A _RetainVerticalSpacingBetweenTokens N/A N/A cur_tok prev_tok N/A N/A N/A Retain vertical spacing between two tokens. N/A N/A prev_tok None N/A N/A N/A N/A prev_tok is_string N/A N/A prev_lineno N/A N/A prev_tok lineno N/A N/A N/A prev_tok value count N/A N/A N/A prev_tok is_pseudo_paren N/A N/A prev_lineno N/A N/A prev_tok previous_token lineno N/A N/A prev_lineno N/A prev_tok lineno N/A N/A cur_tok is_comment N/A N/A cur_lineno N/A N/A cur_tok lineno N/A N/A N/A cur_tok value count N/A N/A cur_lineno N/A cur_tok lineno N/A N/A N/A cur_tok AdjustNewlinesBefore N/A cur_lineno prev_lineno N/A _RetainVerticalSpacingBeforeComments N/A N/A uwline N/A N/A N/A Retain vertical spacing before comments. N/A prev_token None N/A tok N/A uwline tokens N/A N/A N/A N/A tok is_comment prev_token N/A N/A N/A N/A N/A N/A tok lineno N/A N/A N/A tok value count N/A prev_token lineno 1 N/A N/A N/A N/A tok AdjustNewlinesBefore ONE_BLANK_LINE N/A prev_token tok N/A _EmitLineUnformatted N/A N/A state N/A N/A N/A Emit the line without formatting.

  The line contains code that if reformatted would break a non-syntactic
  convention. E.g., i18n comments and function calls are tightly bound by
  convention. Instead, we calculate when / if a newline should occur and honor
  that. But otherwise the code emitted will be the same as the original code.

  Arguments:
    state: (format_decision_state.FormatDecisionState) The format decision
      state.
   N/A prev_lineno None N/A N/A state next_token N/A N/A previous_token N/A N/A state next_token previous_token N/A previous_lineno N/A previous_token lineno N/A N/A previous_token is_multiline_string N/A N/A previous_lineno N/A N/A N/A previous_token value count N/A N/A previous_token is_continuation N/A N/A newline False N/A N/A newline N/A N/A prev_lineno None N/A N/A N/A state next_token lineno previous_lineno N/A prev_lineno N/A N/A state next_token lineno N/A N/A N/A state AddTokenToState newline newline dry_run False N/A _LineContainsI18n N/A N/A uwline N/A N/A N/A 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.

  Returns:
    True if the line contains i18n comments or function calls. False otherwise.
   N/A N/A N/A style Get I18N_COMMENT N/A N/A tok N/A uwline tokens N/A N/A N/A N/A tok is_comment N/A N/A re match N/A N/A style Get I18N_COMMENT N/A tok value N/A N/A True N/A N/A N/A style Get I18N_FUNCTION_CALL N/A N/A length N/A len N/A uwline tokens N/A index 0 N/A N/A index N/A length 1 N/A N/A N/A N/A N/A N/A N/A uwline tokens N/A N/A index 1 value ( N/A N/A N/A N/A uwline tokens N/A index value N/A N/A style Get I18N_FUNCTION_CALL N/A N/A True N/A index 1 N/A False N/A _LineHasContinuationMarkers N/A N/A uwline N/A N/A N/A Return true if the line has continuation markers in it. N/A N/A any N/A N/A tok is_continuation N/A tok N/A uwline tokens N/A _CanPlaceOnSingleLine N/A N/A uwline N/A N/A N/A Determine if the unwrapped line can go on a single line.

  Arguments:
    uwline: (unwrapped_line.UnwrappedLine) The line currently being formatted.

  Returns:
    True if the line can or should be added to a single line. False otherwise.
   N/A indent_amt N/A N/A N/A style Get INDENT_WIDTH N/A uwline depth N/A N/A N/A N/A N/A N/A uwline last total_length indent_amt N/A N/A style Get COLUMN_LIMIT N/A N/A any N/A N/A tok is_comment N/A tok N/A N/A uwline tokens N/A -1 N/A _StateNode N/A object N/A N/A An edge in the solution space from 'previous.state' to 'state'.

  Attributes:
    state: (format_decision_state.FormatDecisionState) The format decision state
      for this node.
    newline: If True, then on the edge from 'previous.state' to 'state' a
      newline is inserted.
    previous: (_StateNode) The previous state node in the graph.
   __init__ N/A N/A self state newline previous N/A N/A N/A N/A self state N/A N/A state Clone N/A N/A self newline newline N/A N/A self previous previous N/A __repr__ N/A N/A self N/A N/A N/A N/A N/A StateNode(state=[
{0}
], newline={1}) format N/A self state N/A self newline N/A N/A N/A _OrderedPenalty N/A N/A collections namedtuple OrderedPenalty N/A penalty count N/A _QueueItem N/A N/A collections namedtuple QueueItem N/A ordered_penalty state_node _AnalyzeSolutionSpace N/A N/A initial_state dry_run N/A False N/A N/A Analyze the entire solution space starting from initial_state.

  This implements a variant of Dijkstra's algorithm on the graph that spans
  the solution space (LineStates are the nodes). The algorithm tries to find
  the shortest path (the one with the lowest penalty) from 'initial_state' to
  the state where all tokens are placed.

  Arguments:
    initial_state: (format_decision_state.FormatDecisionState) The initial state
      to start the search from.
    dry_run: (bool) Don't commit changes if True.

  Returns:
    True if a formatting solution was found. False otherwise.
   N/A count 0 N/A seen N/A set N/A p_queue N/A N/A node N/A _StateNode initial_state False None N/A N/A N/A heapq heappush p_queue N/A _QueueItem N/A _OrderedPenalty 0 count node N/A count 1 N/A prev_penalty 0 N/A p_queue N/A N/A item N/A p_queue N/A 0 N/A penalty N/A N/A item ordered_penalty penalty N/A node N/A item state_node N/A N/A N/A N/A node state next_token N/A N/A N/A N/A N/A heapq heappop p_queue N/A N/A count 10000 N/A N/A N/A N/A node state ignore_stack_for_comparison True N/A N/A N/A node state seen N/A N/A N/A N/A penalty prev_penalty N/A prev_penalty penalty N/A N/A N/A seen add N/A node state N/A count N/A _AddNextStateToQueue penalty node False count p_queue N/A count N/A _AddNextStateToQueue penalty node True count p_queue N/A N/A p_queue N/A N/A False N/A N/A dry_run N/A N/A N/A _ReconstructPath initial_state N/A N/A N/A heapq heappop p_queue state_node N/A True N/A _AddNextStateToQueue N/A N/A penalty previous_node newline count p_queue N/A N/A N/A Add the following state to the analysis queue.

  Assume the current state is 'previous_node' and has been reached with a
  penalty of 'penalty'. Insert a line break if 'newline' is True.

  Arguments:
    penalty: (int) The penalty associated with the path up to this point.
    previous_node: (_StateNode) The last _StateNode inserted into the priority
      queue.
    newline: (bool) Add a newline if True.
    count: (int) The number of elements in the queue.
    p_queue: (heapq) The priority queue representing the solution space.

  Returns:
    The updated number of elements in the queue.
   N/A N/A newline N/A N/A N/A N/A previous_node state CanSplit N/A N/A count N/A N/A N/A newline N/A N/A N/A previous_node state MustSplit N/A N/A count N/A node N/A _StateNode N/A previous_node state newline previous_node N/A penalty N/A N/A N/A node state AddTokenToState newline newline dry_run True N/A N/A N/A heapq heappush p_queue N/A _QueueItem N/A _OrderedPenalty penalty count node N/A N/A count 1 N/A _ReconstructPath N/A N/A initial_state current N/A N/A N/A Reconstruct the path through the queue with lowest penalty.

  Arguments:
    initial_state: (format_decision_state.FormatDecisionState) The initial state
      to start the search from.
    current: (_StateNode) The node in the decision graph that is the end point
      of the path with the least penalty.
   N/A path N/A N/A collections deque N/A N/A current previous N/A N/A N/A N/A path appendleft current N/A current N/A current previous N/A node path N/A N/A N/A N/A initial_state AddTokenToState newline N/A node newline dry_run False N/A _FormatFirstToken N/A N/A first_token indent_depth prev_uwline final_lines N/A N/A N/A Format the first token in the unwrapped line.

  Add a newline and the required indent before the first token of the unwrapped
  line.

  Arguments:
    first_token: (format_token.FormatToken) The first token in the unwrapped
      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.
   N/A N/A N/A first_token AddWhitespacePrefix N/A _CalculateNumberOfNewlines first_token indent_depth prev_uwline final_lines indent_level indent_depth N/A N/A NO_BLANK_LINES 1 N/A ONE_BLANK_LINE 2 N/A TWO_BLANK_LINES 3 _CalculateNumberOfNewlines N/A N/A first_token indent_depth prev_uwline final_lines N/A N/A N/A Calculate the number of newlines we need to add.

  Arguments:
    first_token: (format_token.FormatToken) The first token in the unwrapped
      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.

  Returns:
    The number of newlines needed before the first token.
   N/A N/A prev_uwline None N/A N/A N/A N/A first_token newlines None N/A N/A N/A N/A pytree_utils SetNodeAnnotation N/A N/A first_token GetPytreeNode N/A N/A pytree_utils Annotation NEWLINES None N/A 0 N/A N/A first_token is_docstring N/A N/A NO_BLANK_LINES N/A prev_last_token N/A prev_uwline last N/A N/A prev_last_token is_docstring N/A N/A N/A N/A indent_depth N/A N/A first_token value N/A class def async N/A N/A TWO_BLANK_LINES N/A N/A _NoBlankLinesBeforeCurrentToken N/A prev_last_token value first_token prev_last_token N/A N/A NO_BLANK_LINES N/A N/A ONE_BLANK_LINE N/A N/A N/A first_token value N/A class def @ N/A N/A N/A indent_depth N/A N/A is_inline_comment N/A N/A N/A N/A prev_last_token whitespace_prefix count 0 N/A N/A N/A prev_last_token is_comment N/A is_inline_comment N/A N/A N/A _NoBlankLinesBeforeCurrentToken N/A prev_last_token value first_token prev_last_token N/A N/A index N/A N/A len final_lines 1 N/A N/A index 0 N/A N/A N/A N/A N/A final_lines N/A N/A index 1 is_comment N/A N/A N/A index 1 N/A N/A N/A N/A N/A final_lines N/A N/A index 1 first value @ N/A N/A N/A N/A N/A N/A final_lines N/A index first AdjustNewlinesBefore NO_BLANK_LINES N/A N/A N/A N/A prev_last_token AdjustNewlinesBefore TWO_BLANK_LINES N/A N/A N/A first_token newlines None N/A N/A N/A N/A pytree_utils SetNodeAnnotation N/A N/A first_token GetPytreeNode N/A N/A pytree_utils Annotation NEWLINES None N/A NO_BLANK_LINES N/A N/A N/A N/A N/A prev_uwline first value N/A class def N/A N/A N/A N/A N/A style Get BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF N/A N/A N/A N/A pytree_utils SetNodeAnnotation N/A first_token node N/A N/A pytree_utils Annotation NEWLINES None N/A NO_BLANK_LINES N/A N/A first_token is_comment N/A N/A first_token_lineno N/A N/A first_token lineno N/A N/A N/A first_token value count N/A N/A first_token_lineno N/A first_token lineno N/A N/A N/A first_token_lineno N/A prev_last_token lineno 1 N/A N/A ONE_BLANK_LINE N/A NO_BLANK_LINES N/A _SingleOrMergedLines N/A N/A uwlines N/A N/A N/A Generate the lines we want to format.

  Arguments:
    uwlines: (list of unwrapped_line.UnwrappedLine) Lines we want to format.

  Yields:
    Either a single line, if the current line cannot be merged with the
    succeeding line, or the next two lines merged into one line.
   N/A index 0 N/A last_was_merged False N/A N/A index N/A len uwlines N/A N/A N/A N/A uwlines N/A index disable N/A N/A uwline N/A uwlines N/A index N/A index 1 N/A N/A index N/A len uwlines N/A N/A column N/A N/A N/A uwline last column 2 N/A N/A N/A N/A uwlines N/A index lineno N/A uwline lineno N/A N/A N/A N/A N/A N/A uwline last value : N/A N/A leaf N/A N/A pytree Leaf type N/A token SEMI value ; context N/A N/A N/A uwline lineno column N/A N/A N/A uwline AppendToken N/A N/A format_token FormatToken leaf N/A tok N/A N/A uwlines N/A index tokens N/A N/A N/A N/A uwline AppendToken tok N/A index 1 N/A N/A uwline N/A N/A N/A N/A line_joiner CanMergeMultipleLines N/A uwlines N/A index last_was_merged N/A N/A next_uwline N/A uwlines N/A N/A index 1 N/A tok N/A next_uwline tokens N/A N/A N/A N/A N/A uwlines N/A index AppendToken tok N/A N/A N/A N/A len N/A next_uwline tokens 1 N/A N/A next_uwline first is_multiline_string N/A N/A N/A N/A uwlines N/A index disable True N/A N/A N/A uwlines N/A index N/A index 2 N/A last_was_merged True N/A N/A N/A N/A uwlines N/A index N/A index 1 N/A last_was_merged False N/A _NoBlankLinesBeforeCurrentToken N/A N/A text cur_token prev_token N/A N/A N/A Determine if there are no blank lines before the current token.

  The previous token is a docstring or comment. The prev_token_lineno is the
  start of the text of that token. Counting the number of newlines in its text
  gives us the extent and thus where the line number of the end of the
  docstring or comment. After that, we just compare it to the current token's
  line number to see if there are blank lines between them.

  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
      line.

  Returns:
    True if there is no blank line before the current token.
   N/A cur_token_lineno N/A cur_token lineno N/A N/A cur_token is_comment N/A N/A cur_token_lineno N/A N/A N/A cur_token value count N/A num_newlines N/A N/A N/A prev_token is_comment N/A N/A text count 0 N/A N/A N/A N/A prev_token lineno num_newlines N/A cur_token_lineno 1 N/A