@@ -147,9 +147,9 @@ def __init__(
147147 self ._session_exit_stacks = {}
148148 self ._component_name_hook = component_name_hook
149149
150- async def __aenter__ (self ) -> Self : # pragma: no cover
150+ async def __aenter__ (self ) -> Self :
151151 # Enter the exit stack only if we created it ourselves
152- if self ._owns_exit_stack :
152+ if self ._owns_exit_stack : # pragma: no branch
153153 await self ._exit_stack .__aenter__ ()
154154 return self
155155
@@ -158,22 +158,22 @@ async def __aexit__(
158158 _exc_type : type [BaseException ] | None ,
159159 _exc_val : BaseException | None ,
160160 _exc_tb : TracebackType | None ,
161- ) -> bool | None : # pragma: no cover
161+ ) -> bool | None :
162162 """Closes session exit stacks and main exit stack upon completion."""
163163
164164 # Only close the main exit stack if we created it
165- if self ._owns_exit_stack :
165+ if self ._owns_exit_stack : # pragma: no branch
166166 await self ._exit_stack .aclose ()
167167
168168 # Concurrently close session stacks.
169169 async with anyio .create_task_group () as tg :
170170 for exit_stack in self ._session_exit_stacks .values ():
171- tg .start_soon (exit_stack .aclose )
171+ tg .start_soon (exit_stack .aclose ) # pragma: no cover
172172
173173 @property
174174 def sessions (self ) -> list [mcp .ClientSession ]:
175175 """Returns the list of sessions being managed."""
176- return list (self ._sessions .keys ()) # pragma: no cover
176+ return list (self ._sessions .keys ())
177177
178178 @property
179179 def prompts (self ) -> dict [str , types .Prompt ]:
@@ -323,7 +323,7 @@ async def _establish_session(
323323 await self ._exit_stack .enter_async_context (session_stack )
324324
325325 return result .server_info , session
326- except Exception : # pragma: no cover
326+ except Exception :
327327 # If anything during this setup fails, ensure the session-specific
328328 # stack is closed.
329329 await session_stack .aclose ()
0 commit comments