Refine nexus bridge typing#45
Closed
air17 wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR tightens type-safety across the NexusUnity Python bridge by introducing shared TypedDict/alias definitions and refactoring routing/transport helpers to use them consistently.
Changes:
- Added a private
_types.pymodule with JSON-RPC and payload type definitions. - Updated schemas/constants to use typed definitions (
ToolDefinition,ResourceDefinition,JsonObject). - Refactored routing and transport to return/consume typed JSON-RPC responses and centralized result/error extraction.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Editor/nexus_bridge/schemas.py | Switches schema/tool/resource constants to shared typed definitions. |
| Editor/nexus_bridge/routing.py | Refactors routing helpers to typed JSON-RPC shapes; adds helper accessors for result/error payloads. |
| Editor/nexus_bridge/_types.py | Introduces shared TypeAlias/TypedDict definitions for bridge payloads. |
| Editor/nexus_bridge/_transport.py | Updates call_unity to use the new JSON-RPC request/response types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+188
to
191
| STATIC_RESOURCES: list[ResourceDefinition] = [ | ||
| { | ||
| "uri": "unity://docs/api-reference", | ||
| "name": "API Reference", |
Comment on lines
+78
to
81
| def _apply_created_transform(response: JsonRpcResponse, args: JsonObject) -> JsonRpcResponse: | ||
| instance_id = _extract_created_instance_id(response) | ||
| if not instance_id: | ||
| return response |
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.
This pull request introduces type safety and improved code clarity to the NexusUnity Python bridge by defining and using explicit TypedDict-based types for JSON-RPC communication. The changes include the addition of a new
_types.pymodule containing all relevant type definitions, and a comprehensive refactor of the bridge's core modules to utilize these types. This results in safer, more readable code and easier maintenance.