@@ -109,7 +109,15 @@ class Proxy:
109109 def __init__ (
110110 self , proxied : nodes .ClassDef | nodes .Lambda | Proxy | None = None
111111 ) -> None :
112- if proxied is not None :
112+ if proxied is None :
113+ # This is a hack to allow calling this __init__ during bootstrapping of
114+ # builtin classes and their docstrings.
115+ # For Const and Generator nodes the _proxied attribute is set during bootstrapping
116+ # as we first need to build the ClassDef that they can proxy.
117+ # Thus, if proxied is None self should be a Const or Generator
118+ # as that is the only way _proxied will be correctly set as a ClassDef.
119+ assert isinstance (self , (nodes .Const , Generator ))
120+ else :
113121 self ._proxied = proxied
114122
115123 def __getattr__ (self , name ):
@@ -300,7 +308,7 @@ class Instance(BaseInstance):
300308 # pylint: disable=unnecessary-lambda
301309 special_attributes = lazy_descriptor (lambda : objectmodel .InstanceModel ())
302310
303- def __init__ (self , proxied : nodes .ClassDef ) -> None :
311+ def __init__ (self , proxied : nodes .ClassDef | None ) -> None :
304312 super ().__init__ (proxied )
305313
306314 def __repr__ (self ):
@@ -587,6 +595,8 @@ class Generator(BaseInstance):
587595 Proxied class is set once for all in raw_building.
588596 """
589597
598+ _proxied : nodes .ClassDef
599+
590600 special_attributes = lazy_descriptor (objectmodel .GeneratorModel )
591601
592602 def __init__ (self , parent = None , generator_initial_context = None ):
0 commit comments