python - Pylint error with abstract member variable -
i have following code:
class a(object): def random_function(self): print self.name def abstract_function(self): raise notimplementederror("this abstract class") class b(a): def __init__(self): self.name = "bob" super(b, self).__init__() def abstract_function(self): print "this not abstract class" pylint reports error:
id:e1101 a.random_function: instance of 'a' has no 'name' member
it's true, don't care because abstract. there way rid of warning without suppressing it?
thanks
it best define name in a. consider (or in couple weeks) wants inherit , implement abstract_function:
class c(a): def abstract_function(self): print 'his not abstract class' now following raise error though nothing in c seems wrong:
c = c() c.random_function() if using self.name in should defined there (and lets should default sensible saying not ready use):
class a(object): name = none def random_function(self): print self.name this make code cleaner/less error prone , rid of pylint error.
Comments
Post a Comment