Skip to content

Commit 921352f

Browse files
authored
feat: support python 3.9+ (#36)
1 parent b4b4565 commit 921352f

31 files changed

Lines changed: 1887 additions & 961 deletions

.github/workflows/ci.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
version: "latest"
2121

2222
- name: Setup Python
23-
run: uv python install 3.12
23+
run: uv python install 3.9
2424

2525
- name: Install dependencies
2626
run: uv sync --all-extras
@@ -44,7 +44,7 @@ jobs:
4444
version: "latest"
4545

4646
- name: Setup Python
47-
run: uv python install 3.12
47+
run: uv python install 3.9
4848

4949
- name: Install dependencies
5050
run: uv sync --all-extras
@@ -53,8 +53,11 @@ jobs:
5353
run: uv run ty check drift/ tests/
5454

5555
test:
56-
name: Unit Tests
56+
name: Unit Tests (Python ${{ matrix.python-version }})
5757
runs-on: ubuntu-latest
58+
strategy:
59+
matrix:
60+
python-version: ["3.9", "3.14"]
5861
steps:
5962
- name: Checkout
6063
uses: actions/checkout@v4
@@ -65,7 +68,7 @@ jobs:
6568
version: "latest"
6669

6770
- name: Setup Python
68-
run: uv python install 3.12
71+
run: uv python install ${{ matrix.python-version }}
6972

7073
- name: Install dependencies
7174
run: uv sync --all-extras
@@ -86,7 +89,7 @@ jobs:
8689
version: "latest"
8790

8891
- name: Setup Python
89-
run: uv python install 3.12
92+
run: uv python install 3.9
9093

9194
- name: Install dependencies
9295
run: uv sync --all-extras

.github/workflows/e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
version: "latest"
5555

5656
- name: Setup Python
57-
run: uv python install 3.12
57+
run: uv python install 3.9
5858

5959
- name: Setup Docker Buildx
6060
uses: docker/setup-buildx-action@v3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ For comprehensive guides and API reference, visit our [full documentation](https
3939

4040
## Requirements
4141

42-
- Python 3.12+
42+
- Python 3.9+
4343

4444
Tusk Drift currently supports the following packages and versions:
4545

drift/core/batch_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def _export_batch(self) -> None:
197197
finally:
198198
loop.close()
199199
else:
200-
adapter.export_spans(batch) # type: ignore
200+
adapter.export_spans(batch)
201201

202202
latency_ms = (time.monotonic() - start_time) * 1000
203203
self._metrics.record_spans_exported(len(batch))

drift/core/drift_sdk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def _init_auto_instrumentations(self) -> None:
397397
pass
398398

399399
try:
400-
import urllib3 # type: ignore[unresolved-import]
400+
import urllib3
401401

402402
from ..instrumentation.urllib3 import Urllib3Instrumentation
403403

@@ -452,7 +452,7 @@ def _init_auto_instrumentations(self) -> None:
452452
pass
453453

454454
try:
455-
import django # type: ignore[unresolved-import]
455+
import django
456456

457457
from ..instrumentation.django import DjangoInstrumentation
458458

drift/core/resilience.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from collections.abc import Awaitable, Callable
1414
from dataclasses import dataclass
1515
from enum import Enum
16+
from typing import TypeVar
17+
18+
T = TypeVar("T")
1619

1720
logger = logging.getLogger(__name__)
1821

@@ -51,7 +54,7 @@ def calculate_backoff_delay(
5154
return delay
5255

5356

54-
async def retry_async[T](
57+
async def retry_async(
5558
operation: Callable[[], Awaitable[T]],
5659
config: RetryConfig | None = None,
5760
retryable_exceptions: tuple[type[Exception], ...] = (Exception,),

drift/core/span_serialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from datetime import UTC, datetime, timedelta
5+
from datetime import datetime, timedelta, timezone
66
from typing import Any
77

88
from betterproto.lib.google.protobuf import Struct as ProtoStruct
@@ -114,7 +114,7 @@ def clean_span_to_proto(span: CleanSpanData) -> ProtoSpan:
114114
is_root_span=span.is_root_span,
115115
timestamp=datetime.fromtimestamp(
116116
span.timestamp.seconds + span.timestamp.nanos / 1_000_000_000,
117-
tz=UTC,
117+
tz=timezone.utc,
118118
),
119119
duration=timedelta(
120120
seconds=span.duration.seconds,

drift/core/tracing/adapters/api.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
import gzip
1515
import logging
1616
from dataclasses import dataclass
17-
from datetime import UTC, datetime, timedelta
18-
from typing import TYPE_CHECKING, Any, override
17+
from datetime import datetime, timedelta, timezone
18+
from typing import TYPE_CHECKING, Any
19+
20+
from typing_extensions import override
1921

2022
from ...resilience import (
2123
CircuitBreaker,
@@ -270,7 +272,7 @@ def _transform_span_to_protobuf(self, clean_span: CleanSpanData) -> Any:
270272

271273
timestamp = datetime.fromtimestamp(
272274
clean_span.timestamp.seconds + clean_span.timestamp.nanos / 1_000_000_000,
273-
tz=UTC,
275+
tz=timezone.utc,
274276
)
275277

276278
duration = timedelta(
@@ -339,8 +341,8 @@ def convert_json_schema(sdk_schema: Any) -> Any:
339341
type=type_value,
340342
properties=proto_properties,
341343
items=proto_items,
342-
encoding=encoding_value, # type: ignore[arg-type]
343-
decoded_type=decoded_type_value, # type: ignore[arg-type]
344+
encoding=encoding_value,
345+
decoded_type=decoded_type_value,
344346
match_importance=sdk_schema.match_importance,
345347
)
346348

@@ -370,7 +372,7 @@ def convert_json_schema(sdk_schema: Any) -> Any:
370372
timestamp=timestamp,
371373
duration=duration,
372374
is_root_span=clean_span.is_root_span,
373-
metadata=metadata_struct, # type: ignore[arg-type]
375+
metadata=metadata_struct,
374376
)
375377

376378

drift/core/tracing/adapters/filesystem.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import logging
77
from collections import OrderedDict
88
from dataclasses import asdict
9-
from datetime import UTC, datetime
9+
from datetime import datetime, timezone
1010
from pathlib import Path
11-
from typing import TYPE_CHECKING, Any, override
11+
from typing import TYPE_CHECKING, Any
12+
13+
from typing_extensions import override
1214

1315
from .base import ExportResult, SpanExportAdapter
1416

@@ -63,7 +65,7 @@ def _get_or_create_file_path(self, trace_id: str) -> Path:
6365
return self._trace_file_map[trace_id]
6466

6567
# Create new file with timestamp prefix
66-
iso_timestamp = datetime.now(UTC).isoformat().replace(":", "-").replace(".", "-")
68+
iso_timestamp = datetime.now(timezone.utc).isoformat().replace(":", "-").replace(".", "-")
6769
file_path = self._base_directory / f"{iso_timestamp}_trace_{trace_id}.jsonl"
6870
self._trace_file_map[trace_id] = file_path
6971

drift/core/tracing/adapters/memory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, override
5+
from typing import TYPE_CHECKING
6+
7+
from typing_extensions import override
68

79
from .base import ExportResult, SpanExportAdapter
810

0 commit comments

Comments
 (0)