From 4e5dee2516e08db05dee37ebcabbde3ee741c464 Mon Sep 17 00:00:00 2001 From: Koen van der Veen <7250009+koenvanderveen@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:52:53 +0100 Subject: [PATCH] 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. --- dev-guidelines/guidelines.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dev-guidelines/guidelines.md b/dev-guidelines/guidelines.md index 8a7aa822629..c837f069c85 100644 --- a/dev-guidelines/guidelines.md +++ b/dev-guidelines/guidelines.md @@ -29,6 +29,21 @@ high-level, mid-level and low-level sections below, and so does the `syft-pr-rev - Keep the condition for doing something in the caller, not inside the function. When the function really must check the condition itself, prefix its name with `maybe_`, as in `maybe_do_x()`. + + This also covers a function that returns a value or None, where None means "skip this". Ask the + question with a separate function instead: + + ```python + # not this + note = job._log_note(log_file) + if note: + text += note + + # but this + if job.log_is_truncated(log_file): + text += LOG_TRUNCATION_MESSAGE + ``` + - Aim for 20 lines. A reviewer flags a function or method over 40 lines, unless it: - makes many calls to other functions,