Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable do extract method with try and subscriptable #459

Closed
dryobates opened this issue Mar 15, 2022 · 0 comments · Fixed by #460
Closed

Unable do extract method with try and subscriptable #459

dryobates opened this issue Mar 15, 2022 · 0 comments · Fixed by #460
Labels
bug Unexpected or incorrect user-visible behavior
Milestone

Comments

@dryobates
Copy link
Contributor

Describe the bug
Error while extracting method that contains augmented assignment to subscriptable (dict, list etc.) inside try..except.

To Reproduce
Steps to reproduce the behavior:

  1. Code before refactoring:
any_subscriptable = {0: 0}
try:
    any_subscriptable[0] += 1
except:
    pass
  1. Describe the refactoring you want to do

Extracting method.

  1. Expected code after refactoring:
def extracted():
    any_subscriptable = {0: 0}
    try:
        any_subscriptable[0] += 1
    except:
        pass
extracted()
  1. Describe the error or unexpected result that you are getting
self = <rope.refactor.extract._FunctionInformationCollector object at ...>, node = <ast.AugAssign object at ...>

    def _AugAssign(self, node):
        ast.walk(node.value, self)
>       self._read_variable(node.target.id, node.target.lineno)
E       AttributeError: 'Subscript' object has no attribute 'id'

Editor information (please complete the following information):

  • Project Python version: 3.10.1
  • Rope Python version: 3.10.1
  • Rope version: 0.22.0, 0.23.0
@dryobates dryobates added the bug Unexpected or incorrect user-visible behavior label Mar 15, 2022
dryobates added a commit to dryobates/rope that referenced this issue Mar 15, 2022
dryobates added a commit to dryobates/rope that referenced this issue Mar 15, 2022
dryobates added a commit to dryobates/rope that referenced this issue Mar 15, 2022
@lieryan lieryan added this to the 0.24.0 milestone Mar 16, 2022
@lieryan lieryan modified the milestones: 1.1.0, 1.0.0 Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect user-visible behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants