Ejemplo n.º 1
0
 def multi_line_conditions(self, info):
     node = _parse_text(info.source[info.region[0]:info.region[1]])
     count = usefunction._return_count(node)
     if count > 1:
         raise RefactoringError('Extracted piece can have only one '
                                'return statement.')
     if usefunction._yield_count(node):
         raise RefactoringError('Extracted piece cannot '
                                'have yield statements.')
     if count == 1 and not usefunction._returns_last(node):
         raise RefactoringError('Return should be the last statement.')
     if info.region != info.lines_region:
         raise RefactoringError('Extracted piece should '
                                'contain complete statements.')
Ejemplo n.º 2
0
 def returned(self):
     """Does the extracted piece contain return statement"""
     if self._returned is None:
         node = _parse_text(self.extracted)
         self._returned = usefunction._returns_last(node)
     return self._returned