import gc

class Replacement:
    def __init__(self, class_name, method):
        self.class_name = class_name
        self.method = method

    def __del__(self):

        cls = globals()[self.class_name]
        cls.attr.append( 'decorated by method')

def method_decorator(method):

    class_name = method.__qualname__.rsplit('.', maxsplit=1)[0]
    globals()[class_name] = Replacement(class_name, method)
    return method


def class_decorator(cls):
    cls.attr.append( 'decorated by class')
    return cls



@class_decorator
class A:

    attr = []

    @method_decorator
    def m(self):
        pass



print(A.attr)
# ['decorated by class', 'decorated by method']