Skip to content

Commit 8409979

Browse files
committed
fix(sdk/crewai): add type: ignore[attr-defined] for dynamic event_bus API
Pre-fix the new event-bus bridge in 0.13.9 imports EventBusListener from crewai.events.event_bus and calls crewai_event_bus.scoped_listener without type: ignore[attr-defined]. CI mypy src/ fails with: src/nullrun/instrumentation/crewai.py:188: error: Module "crewai.events.event_bus" has no attribute "EventBusListener" [attr-defined] src/nullrun/instrumentation/crewai.py:208: error: "CrewAIEventsBus" has no attribute "scoped_listener" [attr-defined] because the stubs published for these submodules don't enumerate the public symbols we reach for at runtime. The imports are guarded by except ImportError (pre-1.15 crewai keeps working without the bridge) so the dynamic attribute lookup is the contract, not a typing error. Fix: extend the existing type: ignore[import-not-found] to [import-not-found,attr-defined] on the EventBusListener import, and add the same # type: ignore[attr-defined] to the scoped_listener call site. No runtime behaviour change — pure typing-CI patch. Local verification: * pytest tests/test_crewai_patch.py tests/test_runtime.py tests/test_runtime_branches.py tests/test_track_batch_retry.py tests/test_track_span_context.py tests/test_v3_wire_contract.py — 142 passed, 1 skipped, 2 warnings (same as pre-fix). CI fix; no public API change; no version bump.
1 parent 5e379c9 commit 8409979

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/nullrun/instrumentation/crewai.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def patch_crewai(runtime: Any) -> bool:
183183

184184
try:
185185
from crewai.events import crewai_event_bus # type: ignore[import-not-found]
186-
from crewai.events.event_bus import EventBusListener # type: ignore[import-not-found]
186+
from crewai.events.event_bus import EventBusListener # type: ignore[import-not-found,attr-defined]
187187
except ImportError:
188188
# Pre-1.15 crewai lacks the event bus. Fall through to the
189189
# legacy callback injection so old versions still get
@@ -203,7 +203,7 @@ def patch_crewai(runtime: Any) -> bool:
203203
bridge.listener = lambda event: _on_event(runtime, None, event) # type: ignore[attr-defined]
204204

205205
try:
206-
crewai_event_bus.scoped_listener(bridge)
206+
crewai_event_bus.scoped_listener(bridge) # type: ignore[attr-defined]
207207
except Exception as exc: # pragma: no cover
208208
logger.debug("crewai event_bus registration failed: %s", exc)
209209
return False

0 commit comments

Comments
 (0)