@@ -4,49 +4,80 @@ Writing a good function involves a lot of detail, way too much to remember right
4
4
away! This checklist can help you review your own or your classmates' code until
5
5
the details become a habit.
6
6
7
- ## File Names
7
+ ## Behavior
8
8
9
- - [ ] The file names match the function
10
- - [ ] Test file is named ` /tests/test_file_name.py `
9
+ ### Files
11
10
12
- ## Files
11
+ - [ ] The file name describes the function's behavior
12
+ - [ ] There is a module docstring in the function file
13
+ - [ ] The test file's name matches the function file name -
14
+ ` /tests/test_file_name.py `
15
+ - [ ] There is a module docstring in the tests file
13
16
14
- - [ ] The file names match the function
15
- - [ ] Module header in each file
16
- - [ ] Module docstring in each file
17
-
18
- ## Unit Tests
17
+ ### Unit Tests
19
18
20
19
- [ ] The test class has a helpful name in PascalCase
21
20
- [ ] The test class has a docstring
22
- - Each unit test has
21
+ - Every unit test has
23
22
- [ ] A helpful name
24
23
- [ ] A clear docstring
25
24
- [ ] Only one assertion
26
25
- [ ] There is no logic in the unit test
27
26
- [ ] All tests pass
28
- - [ ] (challenge) Tests for defensive assertions
29
- - [ ] (challenge) Tests for many boundary cases
27
+ - [ ] There are tests for defensive assertions
28
+ - [ ] There are tests for boundary cases
29
+
30
+ ### Function Docstring
31
+
32
+ - [ ] The function's behavior is described
33
+ - The function's arguments are described:
34
+ - [ ] Type
35
+ - [ ] Purpose
36
+ - [ ] Other assumptions (eg. if it's a number, what's the expected range?)
37
+ - The return value is described
38
+ - [ ] Type
39
+ - [ ] Other assumptions are documented
40
+ - The defensive assertions are documented using ` Raises: `
41
+ - [ ] Each assumption about an argument is checked with an assertion
42
+ - [ ] Each assertion checks for _ only one_ assumption about the argument
43
+ - [ ] Include 3 or more (passing!) doctests
44
+
45
+ ### The Function
46
+
47
+ - [ ] The function's name describes it's behavior
48
+ - [ ] The function's name matches the file name
49
+ - _ It's ok to have extra helper functions if necessary, like with mergesort_
50
+ - [ ] The function has correct type annotations
51
+ - [ ] The function is not called at the top level of the function file
52
+ - _ Recursive solutions ** can** call the function from ** inside** the function body_
30
53
31
- ## Function Docstring
54
+ ## Strategy
32
55
33
- - [ ] behavior description
34
- - [ ] parameter description
35
- - [ ] return value description
36
- - [ ] include any assumptions
37
- - [ ] include 3 or more (passing!) doctests
38
- - [ ] assertions are documented (if there are any)
39
- - [ ] include 1-2 use cases (if necessary)
56
+ ### Do's
40
57
41
- ## Function Implementation
58
+ - [ ] Variable names help to understand the strategy
59
+ - [ ] Any comments are clear and describe the strategy
60
+ - [ ] Lines of code are spaced to help show different stages of the strategy
42
61
43
- - [ ] The code is auto-formatted
44
- - [ ] The code has no (reasonable) linting mistakes
62
+ ### Don'ts
63
+
64
+ - [ ] The function's strategy _ is not_ described in any docstrings or tests
65
+ - [ ] Comments explain the _ strategy_ , ** not** the _ implementation_
66
+ - [ ] The function _ does not_ have more comments than code
67
+ - If it does, consider finding a new strategy or a simpler implementation
68
+
69
+ ## Implementation
70
+
71
+ - [ ] The code passes the formatting checks
72
+ - [ ] The code passes all Ruff linting checks
73
+ - [ ] The code has no (reasonable) Pylint errors
74
+ - In code review, you can decide when fixing a Pylint error is helpful and
75
+ when it's too restricting.
45
76
- [ ] Variables are named with snake_case
46
- - [ ] The function has a clear and helpful name
47
- - [ ] The file's name matches the function name
48
- - [ ] The code follows the strategy as simply as possible
49
77
- [ ] Variable names are clear and helpful
50
- - [ ] Comments explain the strategy (if necessary)
51
- - [ ] There are type annotations
52
- - [ ] (challenge) The code includes defensive assertions
78
+ - [ ] The code follows the strategy as simply as possible
79
+ - [ ] The implementation is as simple as possible given the strategy
80
+ - [ ] There are no commented lines of code
81
+ - [ ] There are no ` print ` statements anywhere
82
+ - [ ] The code includes defensive assertions
83
+ - [ ] Defensive assertions include as little logic as possible
0 commit comments