https://bugs.kde.org/show_bug.cgi?id=446683
            Bug ID: 446683
           Summary: Syntax highlighting for property functions is
                    confusing
           Product: kdev-python
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Language support
          Assignee: m...@svenbrauch.de
          Reporter: geisse...@gmail.com
  Target Milestone: ---

Created attachment 144349
  --> https://bugs.kde.org/attachment.cgi?id=144349&action=edit
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

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

Reply via email to