@@ -109,7 +109,15 @@ class Proxy:
109
109
def __init__ (
110
110
self , proxied : nodes .ClassDef | nodes .Lambda | Proxy | None = None
111
111
) -> 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 :
113
121
self ._proxied = proxied
114
122
115
123
def __getattr__ (self , name ):
@@ -300,7 +308,7 @@ class Instance(BaseInstance):
300
308
# pylint: disable=unnecessary-lambda
301
309
special_attributes = lazy_descriptor (lambda : objectmodel .InstanceModel ())
302
310
303
- def __init__ (self , proxied : nodes .ClassDef ) -> None :
311
+ def __init__ (self , proxied : nodes .ClassDef | None ) -> None :
304
312
super ().__init__ (proxied )
305
313
306
314
def __repr__ (self ):
@@ -587,6 +595,8 @@ class Generator(BaseInstance):
587
595
Proxied class is set once for all in raw_building.
588
596
"""
589
597
598
+ _proxied : nodes .ClassDef
599
+
590
600
special_attributes = lazy_descriptor (objectmodel .GeneratorModel )
591
601
592
602
def __init__ (self , parent = None , generator_initial_context = None ):
0 commit comments