Instance Method First Parameter Should Be
Sourcery refactoring id:
Suggests that instance methods should rename their first parameter to
class Chicken: def lay_egg(this, coop): with this.enter_coop(coop): coop.eggs.add(Egg(this.dna))
class Chicken: def lay_egg(self, coop): with self.enter_coop(coop): coop.eggs.add(Egg(self.dna))
This is both a very strong convention in Python and an explicit entry in PEP-8. Adhering to it improves code consistency and makes it easier for developers to understand the intention of your code.
Note that we do not suggest this where there are decorators present, since these can
override the behaviour, meaning that
self is not the correct name.