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

Class _StringifierDict

Lib/annotationlib.py:651–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

649
650
651class _StringifierDict(dict):
652 def __init__(self, namespace, *, globals=None, owner=None, is_class=False, format):
653 super().__init__(namespace)
654 self.namespace = namespace
655 self.globals = globals
656 self.owner = owner
657 self.is_class = is_class
658 self.stringifiers = []
659 self.next_id = 1
660 self.format = format
661
662 def __missing__(self, key):
663 fwdref = _Stringifier(
664 key,
665 globals=self.globals,
666 owner=self.owner,
667 is_class=self.is_class,
668 stringifier_dict=self,
669 )
670 self.stringifiers.append(fwdref)
671 return fwdref
672
673 def transmogrify(self, cell_dict):
674 for obj in self.stringifiers:
675 obj.__class__ = ForwardRef
676 obj.__stringifier_dict__ = None # not needed for ForwardRef
677 if isinstance(obj.__ast_node__, str):
678 obj.__arg__ = obj.__ast_node__
679 obj.__ast_node__ = None
680 if cell_dict is not None and obj.__cell__ is None:
681 obj.__cell__ = cell_dict
682
683 def create_unique_name(self):
684 name = f"__annotationlib_name_{self.next_id}__"
685 self.next_id += 1
686 return name
687
688
689def call_evaluate_function(evaluate, format, *, owner=None):

Callers 2

evaluateMethod · 0.85
call_annotate_functionFunction · 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…