Bug 372273 - Properties setters aren't supported and override the getter
Summary: Properties setters aren't supported and override the getter
Status: CONFIRMED
Alias: None
Product: kdev-python
Classification: Developer tools
Component: Language support (show other bugs)
Version: 5.1.0
Platform: Debian stable Linux
: NOR normal
Target Milestone: ---
Assignee: Sven Brauch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-10 00:58 UTC by Nicolás Alvarez
Modified: 2017-03-24 10:23 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolás Alvarez 2016-11-10 00:58:55 UTC
It seems kdev-python doesn't support @property at all. If I declare a property getter with it, the property is shown as a function. For example:

class Foo:
    @property
    def prop(self):
        return "meow"

    def f(self):
        a = self.prop
        # 'prop' and 'a' are shown as functions, but they should be str
Comment 1 Francis Herne 2016-11-30 10:45:06 UTC
kdev-python doesn't really support decorators in general, there are only special-cases for essential builtin ones.

In this case, @property is only handled in the code-completion, which avoids suggesting brackets.

Really handling decorators will be tricky, especially property() which is quite complicated. Perhaps we could just add more special-cases for the time being.
Comment 2 Francis Herne 2017-01-20 23:02:49 UTC
Git commit eec18d928db9bc1c698569a528819c0b23392dc1 by Francis Herne.
Committed on 20/01/2017 at 23:01.
Pushed by flherne into branch '5.1'.

Very basic property getter support

Property decorators were ignored except for code-completion, trying to
 access properties would get a function rather than the returned type.

Just replace property functions with their return type in
 ExpressionVisitor::visitCall().

This only works for getter-only properties - if there's a setter function
 for the property (which idiomatically has the same name), visitCall() finds
 that declaration instead and gives the wrong return type.

Still, it's useful in a good proportion of cases.

To make this work properly, I think we need a specific declaration type
 for properties, and to update that when visiting the getter/setter
 instead of creating the function declarations directly in the class?

One new test fail->pass.
Two new tests still fail.
No test regressions.

Differential Revision: https://phabricator.kde.org/D4207

M  +13   -7    duchain/expressionvisitor.cpp
M  +19   -3    duchain/tests/pyduchaintest.cpp

https://commits.kde.org/kdev-python/eec18d928db9bc1c698569a528819c0b23392dc1