Skip to content

Commit e4c6ddb

Browse files
observability: PR #19 review followups + CI extras fix
Three changes: - **CI** — ``uv sync --frozen`` didn't install the ``[otel]`` extras, so pyright type-checked ``tests/unit/test_observability_otel.py`` against missing ``opentelemetry.*`` symbols and produced 373 false-positive errors. Switched to ``--all-extras`` so every optional-dependency group is present in CI. - **OTelObserver.spec_version factory** — ``default_factory=lambda: _read_spec_version()`` simplified to ``default_factory=_read_spec_version``; the lambda was a redundant wrapper. - **test_correlation.py** — replaced ``lambda s: _pre(s)`` with the bare ``_pre``; the type-ignore came off too. The other two unnecessary-lambda findings (``detached_subgraphs`` / ``detached_fan_outs`` factories) are kept with an explanatory comment — pyright strict mode infers ``default_factory=frozenset`` as ``frozenset[Unknown]`` and flags it; the lambda preserves the ``frozenset[str]`` annotation.
1 parent b1e1325 commit e4c6ddb

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ jobs:
3636
# version developers run locally.
3737

3838
- name: Sync deps
39-
run: uv sync --frozen
39+
# ``--all-extras`` installs every optional-dependency group
40+
# (currently ``[otel]``) so pyright type-checks the
41+
# OTel-using modules with real types and tests covering
42+
# extras-gated code paths run end-to-end. Without this,
43+
# ``opentelemetry.*`` symbols come back Unknown and pyright
44+
# produces hundreds of false-positive errors on
45+
# ``tests/unit/test_observability_otel.py``.
46+
run: uv sync --frozen --all-extras
4047

4148
- name: Lint (ruff check)
4249
run: uv run ruff check .

src/openarmature/observability/otel/observer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,19 @@ class OTelObserver:
114114
"""
115115

116116
span_processor: SpanProcessor
117+
# Lambda-wrapped factories give pyright the explicit
118+
# ``frozenset[str]`` type — ``default_factory=frozenset``
119+
# alone produces ``frozenset[Unknown]`` which the strict-mode
120+
# config flags. The lambda overhead is negligible (one closure
121+
# call per dataclass instance).
117122
detached_subgraphs: frozenset[str] = field(default_factory=lambda: frozenset[str]())
118123
detached_fan_outs: frozenset[str] = field(default_factory=lambda: frozenset[str]())
119124
disable_llm_spans: bool = False
120125
# Read from the package's ``__spec_version__`` (one of the three
121126
# places the spec version is pinned per CLAUDE.md). Bumping the
122127
# spec submodule + the two version fields automatically updates
123128
# the value reported on every invocation span.
124-
spec_version: str = field(default_factory=lambda: _read_spec_version())
129+
spec_version: str = field(default_factory=_read_spec_version)
125130

126131
# Internal state, populated in __post_init__ and during invocation.
127132
_provider: TracerProvider = field(init=False, repr=False)

tests/unit/test_correlation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async def maybe_fail(_s: _ResumeState) -> dict[str, str | bool]:
156156
# a ``pre`` node whose successful save arms the resume.
157157
pre = (
158158
GraphBuilder(_ResumeState)
159-
.add_node("pre", lambda s: _pre(s)) # type: ignore[arg-type,return-value]
159+
.add_node("pre", _pre)
160160
.add_node("a", maybe_fail)
161161
.add_edge("pre", "a")
162162
.add_edge("a", END)

0 commit comments

Comments
 (0)