Skip to content

Type the optional tracing module loader honestly - #323

Closed
Eigenwise wants to merge 1 commit into
mainfrom
fix/observability-optional-module-typing
Closed

Eigenwise wants to merge 1 commit into
mainfrom
fix/observability-optional-module-typing

Conversation

@Eigenwise

Copy link
Copy Markdown
Owner

What

Pyright reported two reportOptionalMemberAccess errors in atomic_agents/observability/__init__.py. uninstrument() and is_instrumented_by_opentelemetry called _load_tracing_module(), whose return type includes None, right after guards that already rule that case out.

The fix splits the plain import out of the version-guarded loader. The guarded call sites now use _import_tracing_module(), which can't return None. Both functions carry explicit return types.

Why

Shipping a package that fails pyright in its own public module is a bad look for a framework that sells type safety, and Contractify is about to wire this exact class into a pyright-strict codebase. Runtime behavior is unchanged.

Verification

  • uv run pyright atomic-agents/atomic_agents/observability: 0 errors (was 2)
  • uv run pytest atomic-agents/tests/observability: 57 passed
  • uv run pytest --cov=atomic_agents atomic-agents: 659 passed, 3 skipped
  • Black and Flake8 clean on the touched package
  • Radon on the touched bodies: complexity 1 to 3

🤖 Generated with Claude Code

Pyright reported two reportOptionalMemberAccess errors in
atomic_agents/observability/__init__.py: uninstrument() and
is_instrumented_by_opentelemetry called _load_tracing_module(), whose
return type includes None, after guards that already exclude that case.
Split the import out of the version-guarded loader so the guarded call
sites use the import that cannot return None. Runtime behavior is
unchanged: pyright on the package reports 0 errors, the 57 observability
tests and the full core suite (659 passed, 3 skipped) are green.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Eigenwise

Copy link
Copy Markdown
Owner Author

Superseded: #324 rewrote the loader in observability/init.py and pyright is clean on main at b8506eb, so this fix has nothing left to apply to.

@Eigenwise Eigenwise closed this Oct 21, 2026
@Eigenwise
Eigenwise deleted the fix/observability-optional-module-typing branch October 21, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant