https://bugs.kde.org/show_bug.cgi?id=442027

            Bug ID: 442027
           Summary: Variables inside f-strings are not highlighted and not
                    recognised for renaming
           Product: kdev-python
           Version: 5.6.2
          Platform: Neon Packages
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Language support
          Assignee: m...@svenbrauch.de
          Reporter: geisse...@gmail.com
  Target Milestone: ---

SUMMARY
In Python 3.6 f-strings got introduced. They're a simple and well-readable way
to include variables in messages. If a string is preceded with an f character,
variables can be stated inside curly brackets and will automatically get
formatted as a string.

Example:
```python3
x0 = 5
y0 = 20
multiplied = x0 * y0
message = f"Position: ({x0}, {y0}); multiplied {multiplied}"
```

There are lots of nice guides concerning f-string, e. g.
https://www.geeksforgeeks.org/formatted-string-literals-f-strings-python/

Variables inside the f-string curly brackets are apparently not recognised by
KDevelop. There is no syntax highlighting for these variables and they are also
not considered for renaming operations. Renaming either of `x0` or `y0` in the
above example would ignore the occurrence inside the f-string.
This is a likely cause for UnboundLocalErrors: The user renames the variable,
clicks on KDevelop's auto-rename feature and thinks all variables are replaced,
but suddenly the code crashes at f-string formatting becaues the old variable
name is still there.


STEPS TO REPRODUCE
1. Paste any f-string code into KDevelop, for instance the above example. Save
the file for highligthing and semantic analysis to get active.
2. Rename a variable, e. g. `x0` to `xpos`
3. Use the auto-rename feature

OBSERVED RESULT
- Variables inside f-strings are not highlighted
- While all occurrences of a variable outside f-string are replaced properly,
the occurrences inside f-string curly brackets are ignored.

EXPECTED RESULT
- Variables should always be highlighted, also inside f-strings
- Renaming operations should also replace occurrences of the variable in
f-strings

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-27-generic (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION
/

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to