When handling optional/nullable inputs, treat “missing” and “explicitly set to None” as different semantic states.
Practical rules:
None, use a default that keeps the value non-null.
task_id_generator = conf.get("task_id_generator", uuid)
if task_id is None:
task_id = task_id_generator()
time_limit=None (meaning “explicit”), do not collapse it with “argument omitted”. Resolve defaults only when the caller did not provide a value.getattr(x, 'field', None) can be misleading; use presence checks (e.g., __dict__) before applying fallback logic.
actual = getattr(req, 'ignore_result', None)
if isinstance(req, Context) and 'ignore_result' not in req.__dict__:
actual = None # treat as “unset” to allow task-level fallback
if producer is None: return.None and initialize inside the function).Enter the URL of a public GitHub repository