7272DEADLINE_HEAP_MIN_PRUNE_THRESHOLD : Final = 1000
7373
7474# Passed as a sentinel
75- _NO_SEND : Final [" Outcome[Any]" ] = cast ("Outcome[Any]" , object ())
75+ _NO_SEND : Final [Outcome [Any ]] = cast ("Outcome[Any]" , object ())
7676
7777FnT = TypeVar ("FnT" , bound = "Callable[..., Any]" )
7878StatusT = TypeVar ("StatusT" )
@@ -537,8 +537,8 @@ def __enter__(self) -> Self:
537537 def _close (self , exc : BaseException | None ) -> BaseException | None :
538538 if self ._cancel_status is None :
539539 new_exc = RuntimeError (
540- "Cancel scope stack corrupted: attempted to exit {!r} "
541- "which had already been exited" . format ( self )
540+ f "Cancel scope stack corrupted: attempted to exit { self !r} "
541+ "which had already been exited"
542542 )
543543 new_exc .__context__ = exc
544544 return new_exc
@@ -559,10 +559,8 @@ def _close(self, exc: BaseException | None) -> BaseException | None:
559559 # cancel scope it's trying to close. Raise an error
560560 # without changing any state.
561561 new_exc = RuntimeError (
562- "Cancel scope stack corrupted: attempted to exit {!r} "
563- "from unrelated {!r}\n {}" .format (
564- self , scope_task , MISNESTING_ADVICE
565- )
562+ f"Cancel scope stack corrupted: attempted to exit { self !r} "
563+ f"from unrelated { scope_task !r} \n { MISNESTING_ADVICE } "
566564 )
567565 new_exc .__context__ = exc
568566 return new_exc
@@ -1773,9 +1771,7 @@ def task_exited(self, task: Task, outcome: Outcome[Any]) -> None:
17731771 # traceback frame included
17741772 raise RuntimeError (
17751773 "Cancel scope stack corrupted: cancel scope surrounding "
1776- "{!r} was closed before the task exited\n {}" .format (
1777- task , MISNESTING_ADVICE
1778- )
1774+ f"{ task !r} was closed before the task exited\n { MISNESTING_ADVICE } "
17791775 )
17801776 except RuntimeError as new_exc :
17811777 if isinstance (outcome , Error ):
@@ -2596,10 +2592,10 @@ def unrolled_run(
25962592 runner .task_exited (task , msg .final_outcome )
25972593 else :
25982594 exc = TypeError (
2599- "trio.run received unrecognized yield message {!r}. "
2595+ f "trio.run received unrecognized yield message { msg !r} . "
26002596 "Are you trying to use a library written for some "
26012597 "other framework like asyncio? That won't work "
2602- "without some kind of compatibility shim." . format ( msg )
2598+ "without some kind of compatibility shim."
26032599 )
26042600 # The foreign library probably doesn't adhere to our
26052601 # protocol of unwrapping whatever outcome gets sent in.
0 commit comments