chore: Guard that import ldclient does not require aiohttp - #478
Merged
Conversation
joker23
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a regression test asserting that a bare
import ldclientdoes not importaiohttp.aiohttpis an optional dependency (theasyncextra), so sync-only installs do not have it. The async code keeps itsaiohttp-importing pieces (the async client and HTTP transport) off the eager import path:AsyncLDClientis exported lazily, andasync_migratorkeeps itsAsyncLDClientreference behindTYPE_CHECKING.import ldclientalso loadsldclient.migrations, so this covers the async migration surface too.Nothing enforced this invariant before — a future async change could silently make
import ldclientrequireaiohttpand break sync-only users. The test runs in a fresh interpreter so the result is not polluted by other tests that already importedaiohttp.Tracked internally: SDK-60
Note
Low Risk
Test-only change with no production code modifications; low risk to runtime behavior.
Overview
Adds a regression test in
test_aio.py(TestImportSafety) so sync-only installs stay safe: a bareimport ldclientmust not loadaiohttp(optionalasyncextra).The check runs
import ldclientin a fresh subprocess and fails ifaiohttpappears insys.modules, avoiding pollution from other tests that already import async transport code in the same interpreter.Reviewed by Cursor Bugbot for commit f8a06a6. Bugbot is set up for automated code reviews on this repo. Configure here.