Skip to content

fix: resolve pyright type errors in weave instrumentation#529

Open
Alexi5000 wants to merge 1 commit into
microsoft:mainfrom
Alexi5000:pr/fix-weave-pyright-compat
Open

fix: resolve pyright type errors in weave instrumentation#529
Alexi5000 wants to merge 1 commit into
microsoft:mainfrom
Alexi5000:pr/fix-weave-pyright-compat

Conversation

@Alexi5000
Copy link
Copy Markdown

Summary

  • Fix otel_export method signature to use Any types instead of removed OtelExportReq/OtelExportRes types
  • Add missing abstract method stubs (annotation_queue_delete, eval_results_query) to InMemoryWeaveTraceServer

Problem

After running uv upgrade, pyright reports 10 errors in the weave instrumentation:

  1. OtelExportReq and OtelExportRes are no longer attributes of weave.trace_server.trace_server_interface in newer weave versions, causing 6 type errors in instrumentation/weave.py
  2. WeaveTracerManagedTraceServer cannot be instantiated because its parent InMemoryWeaveTraceServer is missing abstract methods added in newer weave releases (eval_results_query, annotation_queue_delete), causing 1 error in tracer/weave.py

Both fixes maintain backward compatibility — the Any types work with both old and new weave versions, and the new stubs follow the existing NotImplementedError pattern for unsupported experimental APIs.

Fixes #496

Test plan

  • uv run pyright -p pyrightconfig.json passes with 0 errors in weave files
  • Existing weave instrumentation tests still pass
  • InMemoryWeaveTraceServer and WeaveTracerManagedTraceServer can be instantiated without TypeError

Fix two categories of pyright errors reported in CI:

1. `OtelExportReq`/`OtelExportRes` were removed from
   `weave.trace_server.trace_server_interface` in newer weave releases.
   Change `otel_export` signature to use `Any` types for forward
   compatibility.

2. `WeaveTracerManagedTraceServer` could not be instantiated because
   the parent `InMemoryWeaveTraceServer` was missing abstract methods
   added in newer weave versions: `annotation_queue_delete` and
   `eval_results_query`. Add stub implementations that raise
   `NotImplementedError`, matching the existing pattern for
   unsupported experimental APIs.

Fixes microsoft#496
Copilot AI review requested due to automatic review settings May 21, 2026 22:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the weave instrumentation shim to remain compatible across multiple weave/tsi versions by loosening type coupling and adding newly required interface methods.

Changes:

  • Updated otel_export to accept/return Any due to removed tsi.OtelExportReq/OtelExportRes in newer weave versions.
  • Added annotation_queue_delete and eval_results_query stubs to satisfy newer abstract interface requirements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +306 to +309
def otel_export(self, req: Any) -> Any:
# OtelExportReq/OtelExportRes were removed from tsi in newer weave versions.
# Use Any to maintain backward compatibility across weave releases.
return None
Comment on lines +470 to +475
# Methods added in newer weave releases to satisfy the abstract interface.
def annotation_queue_delete(self, *args: Any, **kwargs: Any) -> Any:
raise NotImplementedError()

def eval_results_query(self, *args: Any, **kwargs: Any) -> Any:
raise NotImplementedError()
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.

pyright on lint next fails

2 participants