from enum import Enum
class Color(Enum):
red = 1
green = 2
blue = 3
def __lt__(self, other):
return self.value < other.value
$ pylint -d C testcase_enum.py
************* Module testcase_enum
testcase_enum.py:9:15: W0143: Comparing against a callable, did you omit the parenthesis? (comparison-with-callable)
------------------------------------------------------------------
Your code has been rated at 8.57/10 (previous run: 8.57/10, +0.00)
In python 3.4.2 (debian jessie's python), value is defined like so:
@DynamicClassAttribute
def value(self):
"""The value of the Enum member."""
return self._value_
@DynamicClassAttribue is supposed to be like @property but not quite, according to the docstring. I didn't get too much into it.
$ pylint --version
pylint 2.0.0
astroid 2.0.0.dev4
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1]
Thanks for the report! This is a false positive that happens because we can't infer properly the value attribute, will need an update in astroid.
appears to be fixed in recent version
The bug unfortunately is still present with the latest release.
As for now, with the pylint v2.3.1 / astroid v2.2.5 the problem is still actual.
However, for those who lurk for a workaround, here it is:
value = int(self.value)
if value < other.value:
...
With that pylint becomes happy.
Most helpful comment
Thanks for the report! This is a false positive that happens because we can't infer properly the
valueattribute, will need an update inastroid.