Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pylint bug - E1101 & E0102 upon use of @property + @foo.setter

I noticed pylint doesn't handle well the case of:

@property
def foo(self):
   return self._bar.foo

@foo.setter
def foo(self, foo_val):
   self._bar.foo = foo_val

Though it's a perfectly valid case syntax since python2.6

It says I defined foo twice, and doesn't understand the ".setter" syntax (Gives E1101 & E0102).

Is there a workaround for that without having to change the code? I don't want to disable the errors as they are important for other places.

Is there any other tool I can use that handles it better? I already checked pyflakes and it behaves the same way. PyDev's code analysis seems to handle this specific case better, but it doesn't check for conventions, refactoring, and other cool features pylint does, and I can't run it from an external script (or can I??)

Thanks!

like image 474
yonix Avatar asked Oct 20 '10 16:10

yonix


2 Answers

If you don't want to disable the errors globally, you can disable them for these specific lines, for example:

def foo(self, foo_val): # pylint: disable-msg=E0102
like image 110
jchl Avatar answered Oct 25 '22 12:10

jchl


This is ticket http://www.logilab.org/ticket/51222 on the pylint project. Monitor it's status.

like image 20
gurney alex Avatar answered Oct 25 '22 11:10

gurney alex