Introspect recognizes variables added in __new__

Currently introspection is aware of variables defined in __init__

class Example(object):


    def __init__(self):

         self.defined = 1

    def test(self):

         print(self.defined)

         print(self.undefined)  # < Labeled by introspection "Unresolved attribute ..."

but if you defined in __new__ it does not work

class Example(object):


    def __new__(cls):

         obj = super().__new__(cls)

         obj.defined = 1

         return obj

    def test(self):

         print(self.defined)      # < Labeled by introspection "Unresolved attribute ..."

         print(self.undefined)  # < Labeled by introspection "Unresolved attribute ..."

It would be nice if this could work.

Please sign in to leave a comment.