fix: method ordering

This commit is contained in:
David Soria Parra
2025-02-13 10:21:31 +00:00
parent da53a97ed9
commit fbf4acc679
2 changed files with 24 additions and 24 deletions

View File

@@ -459,30 +459,6 @@ class Server(Generic[LifespanResultT]):
return decorator return decorator
async def _handle_message(
self,
message: RequestResponder[types.ClientRequest, types.ServerResult]
| types.ClientNotification
| Exception,
session: ServerSession,
lifespan_context: LifespanResultT,
raise_exceptions: bool = False,
):
with warnings.catch_warnings(record=True) as w:
match message:
case (
RequestResponder(request=types.ClientRequest(root=req)) as responder
):
with responder:
await self._handle_request(
message, req, session, lifespan_context, raise_exceptions
)
case types.ClientNotification(root=notify):
await self._handle_notification(notify)
for warning in w:
logger.info(f"Warning: {warning.category.__name__}: {warning.message}")
async def run( async def run(
self, self,
read_stream: MemoryObjectReceiveStream[types.JSONRPCMessage | Exception], read_stream: MemoryObjectReceiveStream[types.JSONRPCMessage | Exception],
@@ -512,6 +488,30 @@ class Server(Generic[LifespanResultT]):
raise_exceptions, raise_exceptions,
) )
async def _handle_message(
self,
message: RequestResponder[types.ClientRequest, types.ServerResult]
| types.ClientNotification
| Exception,
session: ServerSession,
lifespan_context: LifespanResultT,
raise_exceptions: bool = False,
):
with warnings.catch_warnings(record=True) as w:
match message:
case (
RequestResponder(request=types.ClientRequest(root=req)) as responder
):
with responder:
await self._handle_request(
message, req, session, lifespan_context, raise_exceptions
)
case types.ClientNotification(root=notify):
await self._handle_notification(notify)
for warning in w:
logger.info(f"Warning: {warning.category.__name__}: {warning.message}")
async def _handle_request( async def _handle_request(
self, self,
message: RequestResponder, message: RequestResponder,