MCPcopy Index your code
hub / github.com/python/cpython / _threadsafety_annotation

Function _threadsafety_annotation

Doc/tools/extensions/c_annotations.py:308–347  ·  view source on GitHub ↗
(level: str)

Source from the content-addressed store, hash-verified

306
307
308def _threadsafety_annotation(level: str) -> nodes.emphasis:
309 match level:
310 case "incompatible":
311 display = sphinx_gettext("Not safe to call from multiple threads")
312 reftarget = "threadsafety-level-incompatible"
313 case "compatible":
314 display = sphinx_gettext(
315 "Safe to call from multiple threads"
316 " with external synchronization only"
317 )
318 reftarget = "threadsafety-level-compatible"
319 case "distinct":
320 display = sphinx_gettext(
321 "Safe to call without external synchronization"
322 " on distinct objects"
323 )
324 reftarget = "threadsafety-level-distinct"
325 case "shared":
326 display = sphinx_gettext(
327 "Safe for concurrent use on the same object"
328 )
329 reftarget = "threadsafety-level-shared"
330 case "atomic":
331 display = sphinx_gettext("Atomic")
332 reftarget = "threadsafety-level-atomic"
333 case _:
334 raise AssertionError(f"Unknown thread safety level {level!r}")
335 ref_node = addnodes.pending_xref(
336 display,
337 nodes.Text(display),
338 refdomain="std",
339 reftarget=reftarget,
340 reftype="ref",
341 refexplicit="True",
342 )
343 prefix = " " + sphinx_gettext("Thread safety:") + " "
344 classes = ["threadsafety", f"threadsafety-{level}"]
345 return nodes.emphasis(
346 "", prefix, ref_node, nodes.Text("."), classes=classes
347 )
348
349
350def _return_value_annotation(result_refs: int | None) -> nodes.emphasis:

Callers 1

add_annotationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…