Why this matters
Avoids KeyError and documents fallback behavior.
When keys may be absent, prefer dict.get(key, default) or setdefault instead of direct indexing.
Avoids KeyError and documents fallback behavior.
Side-by-side examples engineers can pattern-match during review.
country = payload['address']['country']country = payload.get('address', {}).get('country', 'unknown')d['x']d.get('x', 0)From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.