Skip to content

Commit 4e5dee2

Browse files
docs: say that None meaning skip is a condition inside the function
PR #9631 had _log_note() return a note or None, where None meant 'add nothing'. Its PR description rated function structure green, because the guideline read as being about functions that do something. Add this case and an example to the guideline.
1 parent 1426534 commit 4e5dee2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎dev-guidelines/guidelines.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ high-level, mid-level and low-level sections below, and so does the `syft-pr-rev
2929

3030
- Keep the condition for doing something in the caller, not inside the function. When the function
3131
really must check the condition itself, prefix its name with `maybe_`, as in `maybe_do_x()`.
32+
33+
This also covers a function that returns a value or None, where None means "skip this". Ask the
34+
question with a separate function instead:
35+
36+
```python
37+
# not this
38+
note = job._log_note(log_file)
39+
if note:
40+
text += note
41+
42+
# but this
43+
if job.log_is_truncated(log_file):
44+
text += LOG_TRUNCATION_MESSAGE
45+
```
46+
3247
- Aim for 20 lines. A reviewer flags a function or method over 40 lines, unless it:
3348

3449
- makes many calls to other functions,

0 commit comments

Comments
 (0)