Menu

#969 valid python decorator error because there is no 'self'

open
Editor (491)
5
2009-09-14
2009-09-14
No

Hello,

I have the following example that doesn't work with pydev version 1.5.0.1251989166.
Here's the exact error message :

"Method 'toto - mypkg' should have self as first parameter"

Here is the code:

def MyProperty(fcn):
"""
U{Source1<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183>}
U{Source2<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410698>}
"""
return property(**fcn())

class A(object):
@MyProperty
def toto():
def fget(self):
return "hello"
return locals()

This sort of code also doesn't work in the code analysis :

# Catch Ctrl-Break in windows
if(hasattr(signal, "SIGBREAK")):
signal.signal(signal.SIGBREAK, self._sigHandler)

I told it to warn me instead of displaying an arror, but this makes the analysis harder to use because I get too many warnings

I understand it's hard to fix this and I could write :

if(hasattr(signal, "SIGBREAK")):
signal.signal(getattr(signal, "SIGBREAK"), self._sigHandler)

in this last case, but it shouldn't force me to program this way (unless you have a good argument, I'm always open for improving my skills).

Here's some useful info :

Pydev version : 1.5.0.1251989166
Eclipse : Version: 3.4.2
Build id: M20090211-1700
OS : linux 2.6 (Ubuntu 8.04)

Discussion