Bug 446683

Summary: Syntax highlighting for property functions is confusing
Product: [Developer tools] kdev-python Reporter: geisserml <geisserml>
Component: Language supportAssignee: Sven Brauch <mail>
Status: RESOLVED REMIND    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Code using property functions in KDevelop
Another example

Description geisserml 2021-12-08 14:16:52 UTC
Created attachment 144349 [details]
Code using property functions in KDevelop

SUMMARY
In Python, there is a concept called property functions. Where you would typically use getter and setter methods in other programming languages, this can be done with proteries in Python. It basically means that custom code can be written to handle attribute access and assignment.

Here's a small, theoretical demo:
```python3
import pikepdf

class PdfHandler:
    
    def __init__(self):
        self._pdf = None
    
    @property
    def pdf(self):
        if self._pdf is not None:
            return self._pdf
        else:
            raise ValueError("No input given")
    
    @pdf.setter
    def pdf(self, file_or_data):
        self._pdf = pikepdf.Pdf.open(file_or_data)
    
    def close(self):
        self._pdf.close()

if __name__ == '__main__':
    handler = PdfHandler()
    handler.pdf = "~/Downloads/Anderes/pdfs/gimp_manual_en.pdf"
    del handler.pdf.pages[4:]
    handler.pdf.save("./out.pdf")
    handler.close()
```
(You can read more about properties here: https://www.learnbyexample.org/python-properties/)

KDevelop highlights property access like normal functions, which is confusing because it implies reassigning the function. I think it would make more sense to highlight properties like normal attributes.

STEPS TO REPRODUCE
1. Paste the above code (or any other code using property functions) into KDevelop
2. See how the property is highlighted

OBSERVED RESULT
It has the same colour as a function call.

EXPECTED RESULT
It should have the colour of an attribute.

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.23
KDE Plasma Version: 5.23.4
KDE Frameworks Version: 5.88.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-41-generic (64-bit)
Graphics Platform: Wayland
Comment 1 geisserml 2021-12-08 14:22:47 UTC
Created attachment 144351 [details]
Another example

The size attribute of :class:`PIL.Image.Image` is a property, too.
Comment 2 geisserml 2023-01-01 16:29:51 UTC
Closing as I'm not using KDevelop anymore.