Skip to content

False positive with useless-super-delegation #2006

@chaNcharge

Description

@chaNcharge

As far as I know, this is a return of issue #1085 and it still seems to be present in the current version of pylint. Here's the code I use:

class Customer(object):
    """
    Attributes:
        name: A string representing the customer's name.
        balance: A float tracking the current balance of the customer's account.
    """

    def __init__(self, name, balance=0.0):
        """Return a Customer object whose name is *name* and starting
        balance is *balance*."""
        self.name = name
        self.balance = balance

    def withdraw(self, amount):
        """Return the balance remaining after withdrawing *amount*
        dollars."""
        if amount > self.balance:
            raise RuntimeError('Amount greater than available balance.')
        self.balance -= amount
        return self.balance

    def deposit(self, amount):
        """Return the balance remaining after depositing *amount*
        dollars."""
        self.balance += amount
        return self.balance

    def bal(self):
        return self.balance

class Subscriber(Customer):
    def __init__(self, name, balance=0.0):
        super().__init__(name, balance)

    def loan(self, amount):
        """Allow withdrawing more than the amount they have, at a cost."""
        self.balance -= amount * 0.1
        print("Taken out {0} (10%) for loan cost".format(amount * 0.1))
        self.balance -= amount
        return self.balance

pylint --version output

pylint-1.8.4,
astroid-1.6.3
Python 3.6.5 (default, Mar 30 2018, 06:41:53)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions