There are problems getting pylint to recognise PyQt4, meaning pylints output is 
next to useless, filled with messages saying classes do not exist.

In case anyone else is suffering this problem, I've attached an email I sent to 
the pylint author containing a patch that will fix the issue.

I hope its useful to someone else - if anyone can cast light on why the bus 
errors might occur when pylint processes QtCore before QtGui that would be 
great too

The Bus Error occurs on my OSX 10.5 box as
0   sip.so                              0x054e5493 compareTypeDef + 13
1   libSystem.B.dylib                   0x90f5c553 bsearch + 51
2   sip.so                              0x054e5512 sip_api_find_type + 66
3   _qt.so                              0x01cc1069 
Chimera::parse_cpp_type(QByteArray const&) + 365
4   _qt.so                              0x01cc12dd Chimera::parse(QByteArray 
const&, char const*) + 333
5   _qt.so                              0x01cc5854 qpycore_get_lazy_attr + 368
6   sip.so                              0x054e74bb add_all_lazy_attrs + 496
7   sip.so                              0x054e75b0 sipWrapperType_getattro + 38
8   org.python.python                   0x001e29c5 recursive_isinstance + 277
9   org.python.python                   0x0024195f type___instancecheck__ + 31

cheers
derek

-----------------------------
Hello,

The more recent releases of PyQt4 seem to break pylint ... pylint will emit the 
following errors
(i) unable to find submodules of PyQt4
   main.py:3: [E0611] No name 'QtCore' in module 'PyQt4'
   main.py:4: [E0611] No name 'QtGui' in module 'PyQt4'
(ii) as a result, all use of classes from eg QtGui, or inheritors from them, 
spark lots of errors
   main.py:11: [E1101, MyValidator] Module 'PyQt4.QtGui2' has no 'QValidator' 
member
   main.py:33: [E1101, DaycountWidget.__init__] Instance of 'DaycountWidget' 
has no 'setEditable' member

I've tracked down the problem I believe ...
* PyQt4.QtCore's namespace has instances of a c-module defined type called 
pyqtSignal
* pylint believes these are methoddescriptors [inspect.ismethoddescriptor(.) -> 
returns true ]
* However, they do not have __name__ or __doc__ defined, which 
logilab/astng/raw_building.py:object_build_methoddescriptor expects

As a result pylint basically refuses to load the Qt modules and this causes all 
subsequent errors.

How to fix?  The following patch will avoid the error

--- logilab/astng/builder.py.orig       2009-07-27 18:43:54.000000000 +1200
+++ logilab/astng/builder.py    2009-07-27 18:44:57.000000000 +1200
@@ -194,8 +194,12 @@
                    # recursion
                    self.object_build(class_node, member)
            elif ismethoddescriptor(member):
-                assert isinstance(member, object)
-                object_build_methoddescriptor(node, member)
+                # avoid objects without __name__, they're not what they seem 
...
+                # (eg PyQt4.QtCore.pyqtSignal instances)
+                if hasattr(member, "__name__") and hasattr(member, "__doc__"):
+                    assert isinstance(member, object)
+                    object_build_methoddescriptor(node, member)
+                else: attach_dummy_node(node, name, member)
            elif isdatadescriptor(member):
                assert isinstance(member, object)
                object_build_datadescriptor(node, member, name)

After this patch pylint seems to work as expected.  However users must ensure 
their code imports PyQt4.QtGui before PyQt4.QtCore or a bus error will occur 
when running pylint. (I have no idea why ... within a python program itself it 
doesn't mind the order in which they are imported).

Hope this is useful, I know that there are a few posts to newsgroups wondering 
how to fix this problem
Derek.

-- 
E-Mail sent with anti-spam site TrashMail.net!
Free disposable email addresses: http://www.trashmail.net

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to