MCPcopy Index your code
hub / github.com/RustPython/RustPython / __annotate__

Function __annotate__

Lib/dataclasses.py:541–569  ·  view source on GitHub ↗
(format, /)

Source from the content-addressed store, hash-verified

539 # from a regular __init__ function
540
541 def __annotate__(format, /):
542 Format = annotationlib.Format
543 match format:
544 case Format.VALUE | Format.FORWARDREF | Format.STRING:
545 cls_annotations = {}
546 for base in reversed(__class__.__mro__):
547 cls_annotations.update(
548 annotationlib.get_annotations(base, format=format)
549 )
550
551 new_annotations = {}
552 for k in annotation_fields:
553 # gh-142214: The annotation may be missing in unusual dynamic cases.
554 # If so, just skip it.
555 try:
556 new_annotations[k] = cls_annotations[k]
557 except KeyError:
558 pass
559
560 if return_type is not MISSING:
561 if format == Format.STRING:
562 new_annotations["return"] = annotationlib.type_repr(return_type)
563 else:
564 new_annotations["return"] = return_type
565
566 return new_annotations
567
568 case _:
569 raise NotImplementedError(format)
570
571 # This is a flag for _add_slots to know it needs to regenerate this method
572 # In order to remove references to the original class when it is replaced

Callers 1

Calls 2

reversedFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected