Scope highlighting does not work with Python decorated functions
CrypticGuru opened this issue · comments
Have you checked the issues and discussions to ensure there are no duplicates?
Yes
Your programming languages
Python
Free or paid?
On trial
Expected Behavior
If a function is decorated, I expect that the highlighting would behave the same as if the function were not decorated.
Current Behavior
If you add a decorator to a function, the highlighting does not focus on the selected function. Instead it seems to do one of 2 things:
- highlight the outer scope (e.g. the entire class of a decorated @classmethod)
- not highlight the function at all
Code snippet for reproduce
"""
Comments added to the two functions/methods that fail to highlight properly.
All the rest seem to highlight as expected.
"""
class MyClass:
"""Serves no functional purpose; only exists for demonstration purposes."""
def __init__(self):
pass
@classmethod
def mymethod(cls): # this method is not properly highlighted
pass
def decorator(func):
def wrapper(val):
val = val.title()
func(val)
return wrapper
@decorator
def myfunc(val): # this function does not get highlighted at all
print(val)
if __name__ == "__main__":
myfunc("hello world!")
Your Environment
PyCharm 2023.3.2 (Professional Edition)
Build #PY-233.13135.95, built on December 19, 2023
[licence information redacted]
Runtime version: 17.0.9+7-b1087.9 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 6.2.0-39-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Registry:
debugger.new.tool.window.layout=true
ide.experimental.ui=true
Non-Bundled Plugins:
com.nasller.CodeGlancePro (1.8.3)
com.markskelton.one-dark-theme (5.10.0)
com.intellij.ml.llm (233.13135.116)
izhangzhihao.rainbow.brackets (2024.2.2-233)
com.koxudaxi.pydantic (0.4.12)
Current Desktop: Regolith:GNOME-Flashback:GNOME
rainbow_decorator_bug_example.mp4
I took a screen capture of me stepping through my original code snippet, hopefully that's helpful to demonstrate what I am seeing.
pls try this build snapshot, don't unzip.
233.zip
pls try this build snapshot, don't unzip. 233.zip
Yes, this appears to fix the issue I reported. Thanks for the speedy reply!!!