fix: resolve pyright type errors in weave instrumentation#529
Open
Alexi5000 wants to merge 1 commit into
Open
Conversation
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
Contributor
There was a problem hiding this comment.
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_exportto accept/returnAnydue to removedtsi.OtelExportReq/OtelExportResin newer weave versions. - Added
annotation_queue_deleteandeval_results_querystubs 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
otel_exportmethod signature to useAnytypes instead of removedOtelExportReq/OtelExportRestypesannotation_queue_delete,eval_results_query) toInMemoryWeaveTraceServerProblem
After running
uv upgrade, pyright reports 10 errors in the weave instrumentation:OtelExportReqandOtelExportResare no longer attributes ofweave.trace_server.trace_server_interfacein newer weave versions, causing 6 type errors ininstrumentation/weave.pyWeaveTracerManagedTraceServercannot be instantiated because its parentInMemoryWeaveTraceServeris missing abstract methods added in newer weave releases (eval_results_query,annotation_queue_delete), causing 1 error intracer/weave.pyBoth fixes maintain backward compatibility — the
Anytypes work with both old and new weave versions, and the new stubs follow the existingNotImplementedErrorpattern for unsupported experimental APIs.Fixes #496
Test plan
uv run pyright -p pyrightconfig.jsonpasses with 0 errors in weave filesInMemoryWeaveTraceServerandWeaveTracerManagedTraceServercan be instantiated withoutTypeError