E2B icon indicating copy to clipboard operation
E2B copied to clipboard

fix(python-sdk): remove dead code in ConnectionConfig.__init__

Open devteamaegis opened this issue 6 months ago • 4 comments

Problem

In ConnectionConfig.__init__, _get_request_timeout is called and its result assigned to self.request_timeout, but that assignment is immediately overwritten by an inline if/elif/else block that duplicates the same logic:

# lines 102-105 — result is never used
self.request_timeout = ConnectionConfig._get_request_timeout(
    REQUEST_TIMEOUT,
    request_timeout,
)

# lines 107-112 — always overwrites the above
if request_timeout == 0:
    self.request_timeout = None
elif request_timeout is not None:
    self.request_timeout = request_timeout
else:
    self.request_timeout = REQUEST_TIMEOUT

_get_request_timeout already implements all three cases identically, so lines 107–112 are unreachable dead code. This creates a misleading impression that the static method is checked before the inline fallback, and silently breaks if someone later changes _get_request_timeout without noticing the duplicate.

Fix

Remove the inline if/elif/else block and rely solely on _get_request_timeout, which is already the method used by get_request_timeout for per-call overrides.

Tests

Added six unit tests to tests/test_connection_config.py covering:

  • default timeout (60 s)
  • explicit timeout value
  • 0 → None (no limit)
  • get_request_timeout() with no argument inherits configured default
  • get_request_timeout(override) returns the override
  • get_request_timeout(0) returns None regardless of config

devteamaegis avatar May 28 '26 07:05 devteamaegis

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Ishaan Samantray. This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

cla-bot[bot] avatar May 28 '26 07:05 cla-bot[bot]

🦋 Changeset detected

Latest commit: 79232f61d680f094ca5e6e354739adb38f566427

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@e2b/python-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar May 28 '26 07:05 changeset-bot[bot]

hey @devteamaegis looks good! could you please sign the CLA?

would like to proceed with merge

mishushakov avatar May 28 '26 12:05 mishushakov

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Ishaan Samantray. This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

cla-bot[bot] avatar May 28 '26 12:05 cla-bot[bot]

@devteamaegis reminder to sign CLA!

mishushakov avatar Jun 02 '26 12:06 mishushakov

CLA not signed, closing stale PR.

mishushakov avatar Jun 05 '26 14:06 mishushakov