[Python-projects] PyLint determines class "newness" incorrectly
skip at pobox.com
skip at pobox.com
Thu Aug 17 22:49:14 CEST 2006
Given this little program:
import pygtk
pygtk.require("2.6")
import gobject
class A(gobject.GObject):
def __init__(self, val):
gobject.GObject.__init__(self)
self._val = val
def _get_val(self):
print "get"
return self._val
def _set_val(self, val):
print "set"
self._val = val
val = property(_get_val, _set_val)
if __name__ == "__main__":
print gobject.GObject.__bases__
a = A(7)
print a.val
a.val = 6
print a.val
When I run it, I get this output:
(<type 'object'>,)
get
7
set
get
6
However, PyLint reports:
gobject_subclass.py:8: [W, A.__init__] __init__ method from a non direct base class <logilab.astng.Yes object at 0x8253d4c> is called
gobject_subclass.py:19: [W, A] Use of "property" on an old style class
It clearly has messed something up about the lineage of the A class. One,
the logilab.astng.Yes class is not involved with the A class. (I believe I
reported this before.) Two, A is a new-style class (because gobject.GObject
is, as the program output demonstrates).
--
Skip Montanaro - skip at pobox.com - http://www.mojam.com/
"On the academic side, effort is too often expended on finding precise
answers to the wrong questions." Baxter & Rennie, in "Financial Calculus"
More information about the Python-Projects
mailing list