On Nov 22, 2015, at 07:04, Adi Roiban <adi@roiban.ro> wrote:

The @deprecated decorator (at leas on py2.7) does not work when paired @property

For deprecated instance variables, our deprecation policy recommend converting them into properties and emitted the  warning from there.
It would be nice if we could use the standard @deprecated decorator here.

The problem is that when property are used the fget/fset are received by the @deprecated wrapper as functions and not as methods

Is there a way to get the class in which a property is defined... or there is no way to use the @deprecated decorator with the @property .. and we should create a dedicated deprecatedMember method which is called as a normal method. 

If you care about inheritance, the implementation is a little bit tricky, because you have to manually walk the class hierarchy looking for the attribute.  But conceptually it's pretty simple: just look at the type of 'oself' in the __get__ method of the returned descriptor.

Right now, @deprecated is hard-coded to assume a function, but it could be repurposed to work with specific other descriptor types reasonably easily.  Arbitrary descriptors might be hard, because it's not clear when to emit the message, but specific types like @property should be pretty straightforward with an instance check.

-glyph