summaryrefslogtreecommitdiff
path: root/doc/data/messages/t/too-few-public-methods/good.py
blob: b0de1ef750ae24a86910a2aa021819789aa46626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import dataclasses


class Worm:
    def __init__(self, name: str, fruit_of_residence: Fruit):
        self.name = name
        self.fruit_of_residence = fruit_of_residence

    def bore(self):
        print(f"{self.name} is boring into {self.fruit_of_residence}")

    def wiggle(self):
        print(f"{self.name} wiggle around wormily.")


# or


@dataclasses.dataclass
class Worm:
    name: str
    fruit_of_residence: Fruit


def bore(worm: Worm):
    print(f"{worm.name} is boring into {worm.fruit_of_residence}")


# or


def bore(fruit: Fruit, worm_name: str):
    print(f"{worm_name} is boring into {fruit}")