Skip to content

Commit a244a18

Browse files
authored
fix: re-enable type checking (#471)
1 parent f2f4e90 commit a244a18

5 files changed

Lines changed: 39 additions & 7 deletions

File tree

.github/scripts/type-checks.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
6+
cd "$REPO_ROOT"
7+
8+
mypy --install-types --non-interactive \
9+
packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python \
10+
packages/aws-durable-execution-sdk-python/tests
11+
12+
mypy --install-types --non-interactive \
13+
packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel \
14+
packages/aws-durable-execution-sdk-python-otel/tests
15+
16+
# comment out this for now as there are many type check errors in this package
17+
#mypy --install-types --non-interactive \
18+
# packages/aws-durable-execution-sdk-python-testing/src/aws_durable_execution_sdk_python_testing \
19+
# packages/aws-durable-execution-sdk-python-testing/tests

packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/deterministic_id_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import re
88
from datetime import datetime, UTC
99

10-
from opentelemetry.sdk.trace import IdGenerator, RandomIdGenerator
10+
from opentelemetry.sdk.trace import RandomIdGenerator
1111

1212
HASH_LENGTH = 16
1313
HASHED_ID_PATTERN = re.compile(r"^[0-9a-f]{16}$")
@@ -65,7 +65,7 @@ def operation_id_to_span_id(operation_id: str) -> int:
6565
return int(hashed_operation_id, 16)
6666

6767

68-
class DeterministicIdGenerator(IdGenerator):
68+
class DeterministicIdGenerator(RandomIdGenerator):
6969
"""An ID generator that produces deterministic span IDs when a pending
7070
operation ID is set, and random IDs otherwise.
7171

packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
from opentelemetry import trace, context
1111
from opentelemetry.context import Context
12+
from opentelemetry.sdk.trace import TracerProvider as SdkTracerProvider
1213
from opentelemetry.sdk.trace.sampling import TraceIdRatioBased
1314
from opentelemetry.trace import (
1415
Tracer,
1516
StatusCode,
1617
SpanContext,
1718
Span,
18-
TracerProvider,
1919
Link,
2020
TraceFlags,
2121
)
@@ -80,7 +80,7 @@ class DurableExecutionOtelPlugin(DurableInstrumentationPlugin):
8080

8181
def __init__(
8282
self,
83-
trace_provider: TracerProvider,
83+
trace_provider: SdkTracerProvider,
8484
context_extractor: ContextExtractor | None = None,
8585
sampling_rate: float = 1.0,
8686
instrument_name: str = DEFAULT_INSTRUMENT_NAME,

packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/execution.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,17 @@ def wrapper(event: Any, context: LambdaContext) -> MutableMapping[str, Any]:
280280
) as executor,
281281
contextlib.closing(execution_state) as execution_state,
282282
):
283+
execution_operation = execution_state.get_execution_operation()
284+
283285
# execute the plugins
284286
plugin_executor.on_invocation_start(
285287
execution_arn=invocation_input.durable_execution_arn,
286288
lambda_context=context,
287-
execution_start_time=execution_state.get_execution_operation().start_timestamp,
289+
execution_start_time=(
290+
execution_operation.start_timestamp
291+
if execution_operation is not None
292+
else None
293+
),
288294
is_first_invocation=not execution_state.is_replaying(),
289295
)
290296
# Thread 1: Run background checkpoint processing

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ requires-python = ">=3.11"
77
workspace.members = ["packages/*"]
88

99
[tool.hatch.envs.test]
10+
detached = true
1011
workspace.members = ["packages/*"]
1112
dependencies = [
1213
"coverage[toml]",
@@ -38,11 +39,17 @@ markers = [
3839
]
3940

4041
[tool.hatch.envs.types]
42+
detached = true
4143
workspace.members = ["packages/*"]
42-
extra-dependencies = ["mypy>=1.0.0", "pytest", "boto3-stubs[lambda]"]
44+
extra-dependencies = [
45+
"mypy>=1.0.0",
46+
"pytest",
47+
"boto3-stubs[lambda]",
48+
"opentelemetry-sdk>=1.20.0",
49+
]
4350

4451
[tool.hatch.envs.types.scripts]
45-
check = "mypy --install-types --non-interactive {args}"
52+
check = "bash .github/scripts/type-checks.sh"
4653

4754
[tool.hatch.envs.dev-core]
4855
workspace.members = ["packages/aws-durable-execution-sdk-python"]

0 commit comments

Comments
 (0)