You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inlining a method whose signature contains type hints fails with an exception.
Removing the type hints, the inlining works just fine.
To Reproduce
Steps to reproduce the behavior:
Code before refactoring:
deffoo(hello: str):
print(hello)
foo("hello")
Describe the refactoring you want to do: Inline foo
Expected code after refactoring:
print("hello")
Describe the error or unexpected result that you are getting
2021-11-03 15:11:44,510 AEDT - ERROR - pylsp_rope.plugin - Exception when doing workspace/executeCommand: Attribute hello: str not found
Traceback (most recent call last):
File "/home/lieryan/Projects/pylsp-rope/pylsp_rope/plugin.py", line 128, in pylsp_execute_command
return commands[command](workspace, **arguments[0])()
File "/home/lieryan/Projects/pylsp-rope/pylsp_rope/plugin.py", line 152, in __call__
rope_changeset = self.get_changes()
File "/home/lieryan/Projects/pylsp-rope/pylsp_rope/plugin.py", line 262, in get_changes
rope_changeset = refactoring.get_changes()
File "/home/lieryan/.virtualenvs/pylsp-rope/lib/python3.9/site-packages/rope/refactor/inline.py", line 153, in get_changes
self._defining_file_changes(
File "/home/lieryan/.virtualenvs/pylsp-rope/lib/python3.9/site-packages/rope/refactor/inline.py", line 203, in _defining_file_changes
result = move.ModuleSkipRenamer(
File "/home/lieryan/.virtualenvs/pylsp-rope/lib/python3.9/site-packages/rope/refactor/move.py", line 842, in get_changed_module
self.handle.occurred_outside_skip(change_collector, occurrence)
File "/home/lieryan/.virtualenvs/pylsp-rope/lib/python3.9/site-packages/rope/refactor/inline.py", line 568, in occurred_outside_skip
definition, returned = self.generator.get_definition(
File "/home/lieryan/.virtualenvs/pylsp-rope/lib/python3.9/site-packages/rope/refactor/inline.py", line 409, in get_definition
return self._calculate_definition(primary, pyname, call, host_vars, returns)
File "/home/lieryan/.virtualenvs/pylsp-rope/lib/python3.9/site-packages/rope/refactor/inline.py", line 465, in _calculate_definition
pyname = pymodule[name]
File "/home/lieryan/.virtualenvs/pylsp-rope/lib/python3.9/site-packages/rope/base/pyobjects.py", line 26, in __getitem__
return self.get_attribute(key)
File "/home/lieryan/.virtualenvs/pylsp-rope/lib/python3.9/site-packages/rope/base/pyobjects.py", line 201, in get_attribute
raise exceptions.AttributeNotFoundError("Attribute %s not found" % name)
rope.base.exceptions.AttributeNotFoundError: Attribute hello: str not found
Screenshots
If applicable, add screenshots to help explain your problem.
Editor information (please complete the following information):
Project Python version: Python 3.9
Rope Python version: Python 3.9
Rope version: 0.21.0
The text was updated successfully, but these errors were encountered:
lieryan
changed the title
Inline refactoring fails when the inlined method contains
Inline refactoring fails when the inline method has type hints
Nov 3, 2021
lieryan
changed the title
Inline refactoring fails when the inline method has type hints
Inline refactoring fails when the inlined method has type hints
Nov 3, 2021
Describe the bug
Inlining a method whose signature contains type hints fails with an exception.
Removing the type hints, the inlining works just fine.
To Reproduce
Steps to reproduce the behavior:
Describe the refactoring you want to do: Inline
foo
Expected code after refactoring:
Screenshots
If applicable, add screenshots to help explain your problem.
Editor information (please complete the following information):
The text was updated successfully, but these errors were encountered: