MCPcopy Create free account
hub / github.com/python/mypy / load_decorated_class

Function load_decorated_class

mypyc/irbuild/classdef.py:918–933  ·  view source on GitHub ↗

Apply class decorators to create a decorated (non-extension) class object. Given a decorated ClassDef and a register containing a non-extension representation of the ClassDef created via the type constructor, applies the corresponding decorator functions on that decorated ClassDef a

(builder: IRBuilder, cdef: ClassDef, type_obj: Value)

Source from the content-addressed store, hash-verified

916
917
918def load_decorated_class(builder: IRBuilder, cdef: ClassDef, type_obj: Value) -> Value:
919 """Apply class decorators to create a decorated (non-extension) class object.
920
921 Given a decorated ClassDef and a register containing a
922 non-extension representation of the ClassDef created via the type
923 constructor, applies the corresponding decorator functions on that
924 decorated ClassDef and returns a register containing the decorated
925 ClassDef.
926 """
927 decorators = cdef.decorators
928 dec_class = type_obj
929 for d in reversed(decorators):
930 decorator = d.accept(builder.visitor)
931 assert isinstance(decorator, Value), decorator
932 dec_class = builder.py_call(decorator, [dec_class], dec_class.line)
933 return dec_class
934
935
936def cache_class_attrs(

Callers 1

finalizeMethod · 0.85

Calls 4

reversedFunction · 0.85
isinstanceFunction · 0.85
acceptMethod · 0.45
py_callMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…