Derek Harland | 27 Jul 08:53 2009

Problem and Fix for PyQt4 and pylint

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
 <at>  <at>  -194,8 +194,12  <at>  <at> 
(Continue reading)

Sylvain Thénault | 28 Jul 14:37 2009
Picon

Re: Problem and Fix for PyQt4 and pylint

On 27 juillet 18:53, Derek Harland wrote:
> Hello,

Hi,

> 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

even if having a fix for this on the pylint/astng side, this is probably
worth mentionning to the pyqt team.

> As a result pylint basically refuses to load the Qt modules and this
> causes all subsequent errors.
(Continue reading)

Derek Harland | 29 Jul 06:30 2009

Re: Problem and Fix for PyQt4 and pylint

Hi Sylvain

* First up, I should point out that I think pylint is a great tool ...  
I use it in combination with flymake in emacs to give me realtime  
error checking which is very helpful.
* I have already posted the suggested fix to the PyQt mailing list,  
along with the note of a bus error
* On the bus error I have more information but will post that separately
* As request, attached is an example simple PyQt app.  Here is what  
the unpatched pylint output appears as

$ pylint-2.6 -f parseable -r n --disable-msg-cat=C,R testcase.py
testcase.py:9: [E0611] No name 'QtGui' in module 'PyQt4'
testcase.py:9: [E0611] No name 'QtCore' in module 'PyQt4'
testcase.py:11: [W0232, TextWidget] Class has no __init__ method
testcase.py:11: [E1101, TextWidget] Module 'PyQt4.QtGui' has no  
'QLineEdit' member
testcase.py:14: [E1101, MainWindow] Module 'PyQt4.QtGui' has no  
'QDialog' member
testcase.py:16: [E1101, MainWindow.__init__] Module 'PyQt4.QtGui' has  
no 'QDialog' member
testcase.py:21: [E1101, MainWindow.init] Module 'PyQt4.QtGui' has no  
'QGroupBox' member
testcase.py:22: [E1101, MainWindow.init] Module 'PyQt4.QtGui' has no  
'QRadioButton' member
testcase.py:23: [E1101, MainWindow.init] Module 'PyQt4.QtGui' has no  
'QRadioButton' member
testcase.py:24: [E1101, MainWindow.init] Module 'PyQt4.QtGui' has no  
'QRadioButton' member
testcase.py:27: [E1101, MainWindow.init] Module 'PyQt4.QtGui' has no  
(Continue reading)

Sylvain Thénault | 29 Jul 13:46 2009
Picon

Re: Problem and Fix for PyQt4 and pylint

On 29 juillet 16:30, Derek Harland wrote:
> Hi Sylvain
> 
> * First up, I should point out that I think pylint is a great tool
> ... I use it in combination with flymake in emacs to give me
> realtime error checking which is very helpful.
> * I have already posted the suggested fix to the PyQt mailing list,
> along with the note of a bus error
> * On the bus error I have more information but will post that separately
> * As request, attached is an example simple PyQt app.  Here is what
> the unpatched pylint output appears as

thanks. Attached is another patch that should do the trick nicely. 
Could you apply it and  tell me if it works well in your environement?

--

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org

Attachment (astng.diff): text/x-diff, 4416 bytes
_______________________________________________
Python-Projects mailing list
Python-Projects <at> lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects
Derek Harland | 29 Jul 23:34 2009

Re: Problem and Fix for PyQt4 and pylint

Hi Sylvain

* Am returning a newer patch to you for raw_building.py --- problem  
here is that __name__ doesn't even exist so this patch just replaces  
constructs like
	member.__name__ or localname
with
	getattr(member, '__name__', None) or localname

to ensure that both blanks and missing get mapped to localname.

* Just to note also, your patch seemed to be against an older version  
of raw_building.py than I have (comes from the 0.19 release).
* I'll be folding these patches into the macports project ... would  
you be so kind as to let me know when a new release comes along that  
no longer needs them?

Derek.

Attachment (patch-raw_building.py): text/x-python-script, 2787 bytes

On 29/07/2009, at 11:46 PM, Sylvain Thénault wrote:

> On 29 juillet 16:30, Derek Harland wrote:
>> Hi Sylvain
>>
>> * First up, I should point out that I think pylint is a great tool
>> ... I use it in combination with flymake in emacs to give me
(Continue reading)

Nicolas Chauvat | 30 Jul 02:03 2009
Picon

Re: Problem and Fix for PyQt4 and pylint

Hi,

On Thu, Jul 30, 2009 at 09:34:12AM +1200, Derek Harland wrote:

> * Just to note also, your patch seemed to be against an older version of 
> raw_building.py than I have (comes from the 0.19 release).

http://www.logilab.org/project/pylint shows that latest release was
0.18.0... what makes you think you have version 0.19 in hand ?

--

-- 
Nicolas Chauvat

logilab.fr - services en informatique scientifique et gestion de connaissances  
Nicolas Chauvat | 30 Jul 02:07 2009
Picon

Re: Problem and Fix for PyQt4 and pylint

On Thu, Jul 30, 2009 at 02:03:20AM +0200, Nicolas Chauvat wrote:
> > * Just to note also, your patch seemed to be against an older version of 
> > raw_building.py than I have (comes from the 0.19 release).
> 
> http://www.logilab.org/project/pylint shows that latest release was
> 0.18.0... what makes you think you have version 0.19 in hand ?

Unless you're talking about
http://www.logilab.org/project/logilab-astng for which the latest
release is 0.19.0.

In that case, you may want to look at
http://hg.logilab.org/logilab/astng/ to see what the current state of
the development code is.

--

-- 
Nicolas Chauvat

logilab.fr - services en informatique scientifique et gestion de connaissances  
Sylvain Thénault | 30 Jul 08:41 2009
Picon

Re: Problem and Fix for PyQt4 and pylint

On 30 juillet 09:34, Derek Harland wrote:
> Hi Sylvain

Hi,

> * Am returning a newer patch to you for raw_building.py --- problem
> here is that __name__ doesn't even exist so this patch just replaces
> constructs like
> 	member.__name__ or localname
> with
> 	getattr(member, '__name__', None) or localname
> 
> to ensure that both blanks and missing get mapped to localname.

done. 

> * Just to note also, your patch seemed to be against an older
> version of raw_building.py than I have (comes from the 0.19
> release).

it was actually the diff with the head revision in our repository (url
nico gave to you). Attached is a diff with the 0.19 version of this file.

> * I'll be folding these patches into the macports project ... would
> you be so kind as to let me know when a new release comes along that
> no longer needs them?

sure, new versions are announced on this list.

--

-- 
(Continue reading)


Gmane