Skip to content

Commit 3921fca

Browse files
Merge pull request #9643 from OpenMined/koen/guideline-optional-return-condition
docs: say that none meaning skip is a condition inside the function
2 parents 1426534 + 4e5dee2 commit 3921fca

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)