Skip to content

Commit a4e74d4

Browse files
julthepPierre-Sassoulaspre-commit-ci[bot]
authored
Add documentation examples for too-few-public-methods (#7066)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 379d0a1 commit a4e74d4

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Worm: # [too-few-public-methods]
2+
def __init__(self, name: str, fruit_of_residence: Fruit):
3+
self.name = name
4+
self.fruit_of_residence = fruit_of_residence
5+
6+
def bore(self):
7+
print(f"{self.name} is boring into {self.fruit_of_residence}")

doc/data/messages/t/too-few-public-methods/details.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
# This is a placeholder for correct code for this message.
1+
import dataclasses
2+
3+
4+
class Worm:
5+
def __init__(self, name: str, fruit_of_residence: Fruit):
6+
self.name = name
7+
self.fruit_of_residence = fruit_of_residence
8+
9+
def bore(self):
10+
print(f"{self.name} is boring into {self.fruit_of_residence}")
11+
12+
def wiggle(self):
13+
print(f"{self.name} wiggle around wormily.")
14+
15+
# or
16+
17+
@dataclasses.dataclass
18+
class Worm:
19+
name:str
20+
fruit_of_residence: Fruit
21+
22+
def bore(worm: Worm):
23+
print(f"{worm.name} is boring into {worm.fruit_of_residence}")
24+
25+
# or
26+
27+
def bore(fruit: Fruit, worm_name: str):
28+
print(f"{worm_name} is boring into {fruit}")

0 commit comments

Comments
 (0)