Skip to content

Commit

Permalink
Merge branch 'master' into issue_293
Browse files Browse the repository at this point in the history
  • Loading branch information
lieryan committed Oct 9, 2021
2 parents 38ec9bd + 214cb56 commit 030d474
Show file tree
Hide file tree
Showing 15 changed files with 2,986 additions and 1,315 deletions.
9 changes: 9 additions & 0 deletions rope/refactor/patchedast.py
Expand Up @@ -97,6 +97,15 @@ def __call__(self, node):
node.sorted_children = ast.get_children(node)

def _handle(self, node, base_children, eat_parens=False, eat_spaces=False):
if hasattr(node, "region"):
# ???: The same node was seen twice; what should we do?
warnings.warn(
"Node <%s> has been already patched; please report!"
% node.__class__.__name__,
RuntimeWarning,
)
return

base_children = collections.deque(base_children)
self.children_stack.append(base_children)
children = collections.deque()
Expand Down
6 changes: 3 additions & 3 deletions rope/refactor/usefunction.py
Expand Up @@ -27,16 +27,16 @@ def _check_returns(self):
node = self.pyfunction.get_ast()
if _yield_count(node):
raise exceptions.RefactoringError(
"Use function should not " "be used on generators."
"Use function should not be used on generatorS."
)
returns = _return_count(node)
if returns > 1:
raise exceptions.RefactoringError(
"usefunction: Function has more " "than one return statement."
"usefunction: Function has more than one return statement."
)
if returns == 1 and not _returns_last(node):
raise exceptions.RefactoringError(
"usefunction: return should " "be the last statement."
"usefunction: return should be the last statement."
)

def get_changes(self, resources=None, task_handle=taskhandle.NullTaskHandle()):
Expand Down

0 comments on commit 030d474

Please sign in to comment.