Refactor protocol and transport modules to use type hints for improved clarity and consistency

- Updated Codec class to use abstract methods for encoding and decoding envelopes.
- Changed Envelope class to use Dict and Optional for payload and error fields.
- Refined error handling in RPCError class with Optional type hints for details.
- Enhanced manifest validation logic with type hints for better type safety.
- Improved plugin loading mechanism with consistent type annotations.
- Updated RPCClient to utilize Optional for codec and connection attributes.
- Refactored transport classes to use Optional for server attributes and socket paths.
This commit is contained in:
DrSmoothl
2026-03-11 00:07:13 +08:00
parent 7f1e79ea28
commit 69219e36f7
19 changed files with 273 additions and 253 deletions

View File

@@ -3,12 +3,14 @@
根据运行平台自动选择最优传输实现。
"""
from typing import Optional
import sys
from .base import TransportClient, TransportServer
def create_transport_server(socket_path: str | None = None) -> TransportServer:
def create_transport_server(socket_path: Optional[str] = None) -> TransportServer:
"""创建传输服务端
Linux/macOS 使用 UDSWindows 使用 TCP 回退。