Use explicit null/undefined checks instead of methods that silently handle missing values. When you expect a value to be present, use access patterns that will fail fast if the value is missing rather than returning default values or silently continuing.
Prefer explicit checks that fail on missing values:
[key]
instead of get(key)
when the key must be present!= None
instead of truthy checks when distinguishing null from empty collectionsExample from code review:
# Instead of using .get() which silently returns None:
ddi_file = source_to_ddi_file_map.get(source_artifact)
# Use direct access that fails if key is missing:
ddi_file = source_to_ddi_file_map[source_artifact]
# For collections, distinguish None from empty:
if lib.pic_objects != None: # Not just: if lib.pic_objects:
# Handle non-null collection (may be empty)
This approach makes your code more robust by catching bugs early when values are unexpectedly missing, rather than allowing silent failures that can be harder to debug later.
Enter the URL of a public GitHub repository