ref(transport): Remove redundant checks for dsn by psh9508 · Pull Request #6104 · getsentry/sentry-python
Description
Related Issue
What changed
Removed the redundant is not None check from the DSN conditional statement in Transport.init (transport.py).
Code Comparison:
# Before if options and options["dsn"] is not None and options["dsn"]: # After if options and options["dsn"]:
Why
In Python, the truthiness check (options["dsn"]) inherently evaluates None as falsy. Therefore, the explicit is not None guard is redundant. Removing it simplifies the logic while maintaining the same behavior.
Notes
- Why not use
options.get('dsn')? While.get()is often used for safe dictionary access, a default value for"dsn"is already guaranteed in this context, so there is no risk of aKeyError. - Consistency: I intentionally kept the direct dictionary access (
options["dsn"]) to remain consistent with the existing coding pattern used later in the same file (e.g., line 1165:if options["dsn"]:).