Skip to content

chore: Guard that import ldclient does not require aiohttp - #478

Merged
jsonbailey merged 3 commits into
mainfrom
jb/sdk-60/import-safety-guard
Aug 4, 2026
Merged

chore: Guard that import ldclient does not require aiohttp#478
jsonbailey merged 3 commits into
mainfrom
jb/sdk-60/import-safety-guard

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Adds a regression test asserting that a bare import ldclient does not import aiohttp.

aiohttp is an optional dependency (the async extra), so sync-only installs do not have it. The async code keeps its aiohttp-importing pieces (the async client and HTTP transport) off the eager import path: AsyncLDClient is exported lazily, and async_migrator keeps its AsyncLDClient reference behind TYPE_CHECKING. import ldclient also loads ldclient.migrations, so this covers the async migration surface too.

Nothing enforced this invariant before — a future async change could silently make import ldclient require aiohttp and break sync-only users. The test runs in a fresh interpreter so the result is not polluted by other tests that already imported aiohttp.

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 bare import ldclient must not load aiohttp (optional async extra).

The check runs import ldclient in a fresh subprocess and fails if aiohttp appears in sys.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.

@jsonbailey
jsonbailey requested a review from a team as a code owner August 3, 2026 23:12
@jsonbailey
jsonbailey merged commit f517330 into main Aug 4, 2026
15 checks passed
@jsonbailey
jsonbailey deleted the jb/sdk-60/import-safety-guard branch August 4, 2026 16:29
@jsonbailey jsonbailey changed the title test: Guard that import ldclient does not require aiohttp chore: Guard that import ldclient does not require aiohttp Aug 4, 2026
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.

2 participants