[Python-projects] list of false negatives

Simon Schampijer simon at schampijer.de
Thu Feb 14 12:30:38 CET 2008


Hi,

I try to use pylint in an project where we use gobject, gtk and dbus. 
Below I have a list of false negatives I found. Regarding gtk I found 
this pointer 
(http://lists.logilab.org/pipermail/python-projects/2006-November/001007.html), 
but could not find something about the gobject issue. Maybe someone can 
comment or provide me with pointers I can look at, thanks.

Best,
    Simon


* dbus conversion
  - dbus.String(self._key)
  - E1102: dbus.String is not callable
  - works in 0.41

* Message has unused arguments
  - W0613: Unused argument 'arg0'
<example>
def __new_picture(self, playa, pixbuf):
         self.emit('pixbuf', pixbuf)
</example>
  - workaround: prefix method with 'cb_' or append '_cb', this seems 
hardcoded in the pylint code why I think this can not be customized to 
match for example '__'

* gobject
  - E1101: Instance of 'LiveVideoSlot' has no 'emit' member
  same behavior for 'connect', 'disconnect', 'notify', props

What does not work:
<example>
class LiveVideoSlot(gobject.GObject):
     __gsignals__ = {
         'pixbuf': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, 
([gobject.TYPE_PYOBJECT])),
     }
     def __init__(self, width, height):
         gobject.GObject.__init__(self)

     def _new_picture_cb(self, playa, pixbuf):
         self.emit('pixbuf', pixbuf)
</example>

What does work:
<example>
class LiveVideoSlot(gtk.EventBox):
     __gsignals__ = {
         'pixbuf': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, 
([gobject.TYPE_PYOBJECT])),
     }
     def __init__(self, width, height):
         gtk.EventBox.__init__(self)

     def _new_picture_cb(self, playa, pixbuf):
         self.emit('pixbuf', pixbuf)
</example>

* vbox keydialog
  - E1101: 96:KeyDialog.__init__: Class 'vbox' has no 'pack_start' member
self.vbox.__module__ is gtk
<example>
class KeyDialog(gtk.Dialog):
     def __init__(self):
         gtk.Dialog.__init__(self, flags=gtk.DIALOG_MODAL)
         self.set_title("Wireless Key Required")
         label = gtk.Label("Label")
         self.vbox.pack_start(label)
</example>

* gtk.Window
E1101: 10:ActivityChatWindow.__init__: Class 'window' has no 
'set_type_hint' member
E1101: 11:ActivityChatWindow.__init__: Class 'window' has no 
'set_accept_focus' member

calling self.set_type_hint() works for pylint
self.window.__module__ is gtk.gdk
<example>
class ActivityChatWindow(gtk.Window):
     def __init__(self):
         gtk.Window.__init__(self)

         self.realize()
         self.set_decorated(False)
         self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
         self.window.set_accept_focus(True)
ActivityChatWindow()
</example>

* child
E1101: 10:ClipboardIcon.__init__: Class 'child' has no 'connect' member

calling self.connect() works for pylint
self.child is of type GtkRadioButton and __module__ is gtk

<example>
from sugar.graphics.radiotoolbutton import RadioToolButton

class ClipboardIcon(RadioToolButton):
     __gtype_name__ = 'SugarClipboardIcon'

     def __init__(self):
         RadioToolButton.__init__(self)
         self.child.connect('drag_data_get', self._drag_data_get_cb)

     def _drag_data_get_cb(self, widget, context, selection, targetType, 
eventTime):
         pass
</example>



More information about the Python-Projects mailing list