summaryrefslogtreecommitdiff
path: root/doc/data/messages/t/too-few-public-methods/good.py
blob: ca4b5b6fb36a303cf2a24323a5c1c1d5f7244b7e (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
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}")