Skip to content

ref(transport): Remove redundant checks for dsn#6104

Open
psh9508 wants to merge 3 commits intogetsentry:masterfrom
psh9508:refactor/dns-check
Open

ref(transport): Remove redundant checks for dsn#6104
psh9508 wants to merge 3 commits intogetsentry:masterfrom
psh9508:refactor/dns-check

Conversation

@psh9508
Copy link
Copy Markdown

@psh9508 psh9508 commented Apr 21, 2026

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 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"]:).

@psh9508 psh9508 requested a review from a team as a code owner April 21, 2026 02:04
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (ci) Cancel in-progress PR workflows on new commit push by joshuarli in #5994
  • (consts) Add updated span convention constants to SPANDATA by ericapisani in #6093
  • Add db.driver.name spans to database integrations by ericapisani in #6082

Bug Fixes 🐛

  • (google_genai) Redact binary data in inline_data and fix multi-part message extraction by ericapisani in #5977
  • (grpc) Add isolation_scope to async server interceptor by robinvd in #5940
  • (openai-agents) Resolve agent from bindings for openai-agents >= 0.14 by ericapisani in #6102
  • (profiler) Stop nulling buffer on teardown by ericapisani in #6075

Internal Changes 🔧

  • (celery) Remove unused NoOpMgr from utils by sentrivana in #6078
  • (ci) Update outdated pinned action version comments by JoshuaMoelans in #6088
  • (pydantic-ai) Remove dead Model.request patch by alexander-alderman-webb in #5956
  • (tests) Replace deprecated enable_tracingwith traces_sample_rate by sentrivana in #6077
  • (transport) Remove redundant checks for dsn by psh9508 in #6104
  • 🤖 Update test matrix with new releases (04/20) by github-actions in #6100
  • Set explicit base-branch for codecov action by ericapisani in #5992

🤖 This preview updates automatically when you update the PR.

@sentrivana sentrivana enabled auto-merge (squash) April 21, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ref(transport): Simplify redundant DSN check in Transport.__init__

2 participants