Skip to content

Commit 06b6c27

Browse files
fix: add coverage optional extra, fix docs install instructions, reorder init
- Add coverage>=7.0.0 as optional dependency [coverage] extra in pyproject.toml - Fix docs to reference correct package name tusk-drift-python-sdk[coverage] - Move start_coverage_collection() after _initialized guard to avoid wasteful re-invocation
1 parent c71dd37 commit 06b6c27

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

docs/coverage.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ The Python SDK collects per-test code coverage during Tusk Drift replay using `c
55
## Requirements
66

77
```bash
8-
pip install coverage
9-
# or
10-
pip install tusk-drift[coverage]
8+
pip install tusk-drift-python-sdk[coverage]
119
```
1210

1311
If `coverage` is not installed when coverage is enabled, the SDK logs a warning and coverage is skipped. Tests still run normally.

drift/core/drift_sdk.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ def initialize(
160160

161161
configure_logger(log_level=log_level, prefix="TuskDrift")
162162

163-
# Start coverage collection early (before any SDK mode checks that might return early).
164-
# Coverage data is accessed via protobuf channel (communicator handles requests).
165-
from .coverage_server import start_coverage_collection
166-
167-
start_coverage_collection()
168-
169163
instance._init_params = {
170164
"api_key": api_key,
171165
"env": env,
@@ -185,6 +179,13 @@ def initialize(
185179
)
186180
env = env_from_var
187181

182+
# Start coverage collection early (before any SDK mode checks that might return early),
183+
# but after the _initialized guard so we don't re-invoke on repeated initialize() calls.
184+
# Coverage data is accessed via protobuf channel (communicator handles requests).
185+
from .coverage_server import start_coverage_collection
186+
187+
start_coverage_collection()
188+
188189
if cls._initialized:
189190
logger.debug("Already initialized, skipping...")
190191
return instance

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies = [
4444
flask = ["Flask>=3.1.2"]
4545
fastapi = ["fastapi>=0.115.6", "uvicorn>=0.34.2", "starlette<0.42.0"]
4646
django = ["Django>=4.2"]
47+
coverage = ["coverage>=7.0.0"]
4748
rust = ["drift-core-python>=0.1.9"]
4849
dev = [
4950
"Flask>=3.1.2",

uv.lock

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)