Skip to content

Commit 1b72b88

Browse files
authored
ref(transport): Remove redundant checks for dsn (#6104)
### Description #### Related Issue * Fixes #6089 #### What changed Removed the redundant `is not None` check from the DSN conditional statement in `Transport.init` (`transport.py`). **Code Comparison:** ```python # 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 a `KeyError`. * **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"]:`).
1 parent 1faec55 commit 1b72b88

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

sentry_sdk/transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Transport(ABC):
106106

107107
def __init__(self: "Self", options: "Optional[Dict[str, Any]]" = None) -> None:
108108
self.options = options
109-
if options and options["dsn"] is not None and options["dsn"]:
109+
if options and options["dsn"]:
110110
self.parsed_dsn = Dsn(options["dsn"], options.get("org_id"))
111111
else:
112112
self.parsed_dsn = None

0 commit comments

Comments
 (0)