parameters: (script)
return_statement: return Refactoring(dct)
docstring: :type script: api.Script
docstring_summary: :type script: api.Script
docstring_tokens: : type script : api . Script
function: def inline(script):
      """
      :type script: api.Script
      """
      new_lines = split_lines(python_bytes_to_unicode(script.source))
  
      dct = {}
  
      definitions = script.goto_assignments()
      assert len(definitions) == 1
      stmt = definitions[0]._definition
      usages = script.usages()
      inlines = [r for r in usages
                 if not stmt.start_pos <= (r.line, r.column) <= stmt.end_pos]
      inlines = sorted(inlines, key=lambda x: (x.module_path, x.line, x.column),
                       reverse=True)
      expression_list = stmt.expression_list()
      # don't allow multi-line refactorings for now.
      assert stmt.start_pos[0] == stmt.end_pos[0]
      index = stmt.start_pos[0] - 1
  
      line = new_lines[index]
      replace_str = line[expression_list[0].start_pos[1]:stmt.end_pos[1] + 1]
      replace_str = replace_str.strip()
      # tuples need parentheses
      if expression_list and isinstance(expression_list[0], pr.Array):
          arr = expression_list[0]
          if replace_str[0] not in ['(', '[', '{'] and len(arr) > 1:
              replace_str = '(%s)' % replace_str
  
      # if it's the only assignment, remove the statement
      if len(stmt.get_defined_names()) == 1:
          line = line[:stmt.start_pos[1]] + line[stmt.end_pos[1]:]
  
      dct = _rename(inlines, replace_str)
      # remove the empty line
      new_lines = dct[script.path][2]
      if line.strip():
          new_lines[index] = line
      else:
          new_lines.pop(index)
  
      return Refactoring(dct)
function_tokens: def inline ( script ) : new_lines = split_lines ( python_bytes_to_unicode ( script . source ) ) dct = { } definitions = script . goto_assignments ( ) assert len ( definitions ) == 1 stmt = definitions [ 0 ] . _definition usages = script . usages ( ) inlines = [ r for r in usages if not stmt . start_pos <= ( r . line , r . column ) <= stmt . end_pos ] inlines = sorted ( inlines , key = lambda x : ( x . module_path , x . line , x . column ) , reverse = True ) expression_list = stmt . expression_list ( ) # don't allow multi-line refactorings for now. assert stmt . start_pos [ 0 ] == stmt . end_pos [ 0 ] index = stmt . start_pos [ 0 ] - 1 line = new_lines [ index ] replace_str = line [ expression_list [ 0 ] . start_pos [ 1 ] : stmt . end_pos [ 1 ] + 1 ] replace_str = replace_str . strip ( ) # tuples need parentheses if expression_list and isinstance ( expression_list [ 0 ] , pr . Array ) : arr = expression_list [ 0 ] if replace_str [ 0 ] not in [ '(' , '[' , '{' ] and len ( arr ) > 1 : replace_str = '(%s)' % replace_str # if it's the only assignment, remove the statement if len ( stmt . get_defined_names ( ) ) == 1 : line = line [ : stmt . start_pos [ 1 ] ] + line [ stmt . end_pos [ 1 ] : ] dct = _rename ( inlines , replace_str ) # remove the empty line new_lines = dct [ script . path ] [ 2 ] if line . strip ( ) : new_lines [ index ] = line else : new_lines . pop ( index ) return Refactoring ( dct )