pylint-bot / pylint-unofficial

UNOFFICIAL playground for pylint github migration
0 stars 0 forks source link

Explicit call of magic method: should give warning? #327

Open pylint-bot opened 10 years ago

pylint-bot commented 10 years ago

Originally reported by: Łukasz Rogalski (BitBucket: rogalski, GitHub: @rogalski?)


In typical cases, explicit call to magic method should be considered as violation. Consider this example:

#!python
class Comparable(object):
    def __cmp__(self, other):
        return some_integer

cmp1 = Comparable()
cmp2 = Comparable()

print cmp1 == cmp2 # correct
print cmp1 > cmp2 # correct
print cmp1.__cmp__(cmp2) # violation

pylint-bot commented 10 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


True, we should emit a warning for this case.