Skip to content

Commit 12692ff

Browse files
committed
refactor: remove unnecessary try-except in _should_validate_notification
The try-except block was unnecessary since getattr already handles the case where the attribute doesn't exist by returning None.
1 parent e702f9e commit 12692ff

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/mcp/shared/session.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,10 @@ def _should_validate_notification(self, message_root: JSONRPCNotification) -> bo
294294
Determines if a notification should be validated.
295295
Internal notifications (like notifications/cancelled) should be ignored.
296296
"""
297-
try:
298-
return (
299-
getattr(message_root, "method", None) != "notifications/cancelled" and
300-
not self._closed
301-
)
302-
except:
303-
return False
297+
return (
298+
getattr(message_root, "method", None) != "notifications/cancelled" and
299+
not self._closed
300+
)
304301

305302
async def _receive_loop(self) -> None:
306303
async with (

0 commit comments

Comments
 (0)