On Thu, 2015-04-23 at 14:54 -0400, Chris Lumens wrote:
---
blivet/size.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/blivet/size.py b/blivet/size.py
index 29d2cb6..42e5612 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -294,8 +294,13 @@ class Size(Decimal):
return Size(Decimal.__mul__(self, other))
__rmul__ = __mul__
- 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.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic