> - def __div__(self, other, context=None):
> - return Size(Decimal.__div__(self, other))
> + # Only python2 Decimal objects have a __div__ method.
> + if six.PY2:
> + # But pylint running under python3 still has to be told to ignore this,
> + # because it'll get through the six guard anyway.
> + # pylint: disable=no-member
> + def __div__(self, other, context=None):
> + return Size(Decimal.__div__(self, other))
I'm not 100% sure about this -- in Python 2 the __div__ method should be
never called and if it is, it's a bug in the caller code. So we may as
well just add the pylint disable without the if that is quite weird at
this scope ("maybe define a method"). If we really want to have this if,
it should be inside the __div__ method with the else branch raising an
exception.
Well, I wasn't sure about this either. I agree about the if there, but
it is valid python. The problem here is that in python3, Decimal
objects just don't have a __div__ method, so there's really nothing for
us to be overriding here. I assume it would never be called anyway.
You can check it out for yourself:
clumens@dhcp55:~/src/anaconda (master=)$ python3
Python 3.4.2 (default, Jan 12 2015, 12:13:20)
[GCC 4.9.2 20150107 (Red Hat 4.9.2-5)] on linux
Type "help", "copyright", "credits" or "license"
for more information.
>> import decimal
>> dir(decimal.Decimal)
['__abs__', '__add__',
'__bool__', '__ceil__', '__class__', '__complex__',
'__copy__', '__deepcopy__', '__delattr__', '__dir__',
'__divmod__', '__doc__', ...
I can do whatever - it's not my project. I just want to make sure
pylint shuts up, and it does appear to have found a valid problem in
this case.
- Chris