Pylint bug - E1101 and E0102 when using @property + @ foo.setter

I noticed that pylint is not handling the case:

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

Although this is completely correct case syntax, since python2.6

It says that I defined foo twice and did not understand the ".setter" syntax (gives E1101 and E0102).

Is there a workaround for this without having to change the code? I do not want to disable errors, as they are important for other places.

Is there any other tool I can use that handles it better? I already tested pyflakes and it behaves the same. Analyzing the PyDev code seems to do better with this particular case, but it does not check the conventions, refactoring, and other interesting pylint functions, and I cannot run it from an external script (or can I?)

Thanks!

+4
source share
4 answers

This is the ticket http://www.logilab.org/ticket/51222 in the pylint project. Monitor his status.

+2
source

If you do not want to disable errors globally, you can disable them for these specific lines, for example:

 def foo(self, foo_val): # pylint: disable-msg=E0102 
+4
source

Yes. Annoying. And all the main tools that I could find (pyflakes, pylint, pychecker) demonstrate this problem. It seems like the problem starts with byte code, but I can't get dis to give me a byte code for the properties of the object.

It sounds like you would be better off using this syntax:

 # Changed to longer member names to reduce pylint grousing class HughClass(object): def __init__(self, init_value): self._hugh = init_value def hugh_setter(self): return self._hugh * 2 def hugh_getter(self, value): self._hugh = value / 2 hugh = property(hugh_getter, hugh_setter) 

Here is a good blog article . LOL quote:

Getters and setters belong to the sad world of Java and C ++.

+1
source

It was like a bug in pyflakes , and it seems to be fixed in the current line. So I think the answer is (now): pyflakes!

0
source

All Articles