memestra icon indicating copy to clipboard operation
memestra copied to clipboard

Memestra doesn't work with methods

Open marimeireles opened this issue 5 years ago • 1 comments

Was trying to write an example for the blogpost and got this:

import deprecated


@deprecated.deprecated('This function will be removed on Feb. 2100.')
def some_old_function(x, y):
    return x + y


# You can also decorate a class or a method:
class SomeClass(object):
    @deprecated.deprecated('kkkkk')
    def some_old_method(self, x, y):
        return x + y


@deprecated.deprecated('Use another class.')
class SomeOldClass(object):
    pass


some_old_function(2, 3)

some_obj = SomeClass()

some_obj.some_old_method(4, 5)

SomeOldClass()

Everything is captured by memestra but some_obj.some_old_method(4, 5).

I checked our tests and we're actually not covering it at all. I think we forgot. Can help on this fix after this hectic week.

marimeireles avatar Sep 15 '20 14:09 marimeireles

Well, there's a good reason we don't support it: when a method is accessed, we need to know the type of the object in order to determine which code gets executed.

Some things we can do:

  1. raise a warning because we don't know how to handle it.
  2. use type information, if any, to track variable types and thus resolve method calls
  3. assume that if a method is deprecated, all methods with the same name are deprecated

@SylvainCorlay any thoughts?

serge-sans-paille avatar Sep 15 '20 15:09 serge-sans-paille