rope
rope copied to clipboard
Inlining string constant into f-string should be smarter
Describe the bug
Inlining expression containing string constant into f-string should take into consideration the surrounding f-string's quote.
To Reproduce Steps to reproduce the behavior:
- Code before refactoring:
msg = "hello"
s = f"foo: {msg}"
-
Inline "msg"
-
Expected code after refactoring, should be either:
s = f"foo: {'hello'}"
or maybe even special case the situation where
s = f"foo: hello"
- Describe the error or unexpected result that you are getting
s = f"foo: {"hello"}"
which is not a valid code because the double quotes cannot be parsed properly by Python:
SyntaxError: f-string: expecting '}'
Editor information (please complete the following information):
- Project Python version: 3.9.5
- Rope Python version: 0.9.5
- Rope version: 0.20.1