@@ -474,18 +474,36 @@ def _astroid_bootstrapping():
474
474
# Set the builtin module as parent for some builtins.
475
475
nodes .Const ._proxied = property (_set_proxied )
476
476
477
- _GeneratorType = nodes .ClassDef (
478
- types .GeneratorType .__name__ , types .GeneratorType .__doc__
479
- )
477
+ _GeneratorType = nodes .ClassDef (types .GeneratorType .__name__ )
480
478
_GeneratorType .parent = astroid_builtin
479
+ generator_doc_node = (
480
+ nodes .Const (value = types .GeneratorType .__doc__ )
481
+ if types .GeneratorType .__doc__
482
+ else None
483
+ )
484
+ _GeneratorType .postinit (
485
+ bases = [],
486
+ body = [],
487
+ decorators = None ,
488
+ doc_node = generator_doc_node ,
489
+ )
481
490
bases .Generator ._proxied = _GeneratorType
482
491
builder .object_build (bases .Generator ._proxied , types .GeneratorType )
483
492
484
493
if hasattr (types , "AsyncGeneratorType" ):
485
- _AsyncGeneratorType = nodes .ClassDef (
486
- types .AsyncGeneratorType .__name__ , types .AsyncGeneratorType .__doc__
487
- )
494
+ _AsyncGeneratorType = nodes .ClassDef (types .AsyncGeneratorType .__name__ )
488
495
_AsyncGeneratorType .parent = astroid_builtin
496
+ async_generator_doc_node = (
497
+ nodes .Const (value = types .AsyncGeneratorType .__doc__ )
498
+ if types .AsyncGeneratorType .__doc__
499
+ else None
500
+ )
501
+ _AsyncGeneratorType .postinit (
502
+ bases = [],
503
+ body = [],
504
+ decorators = None ,
505
+ doc_node = async_generator_doc_node ,
506
+ )
489
507
bases .AsyncGenerator ._proxied = _AsyncGeneratorType
490
508
builder .object_build (bases .AsyncGenerator ._proxied , types .AsyncGeneratorType )
491
509
builtin_types = (
@@ -502,10 +520,16 @@ def _astroid_bootstrapping():
502
520
)
503
521
for _type in builtin_types :
504
522
if _type .__name__ not in astroid_builtin :
505
- cls = nodes .ClassDef (_type .__name__ , _type .__doc__ )
506
- cls .parent = astroid_builtin
507
- builder .object_build (cls , _type )
508
- astroid_builtin [_type .__name__ ] = cls
523
+ klass = nodes .ClassDef (_type .__name__ )
524
+ klass .parent = astroid_builtin
525
+ klass .postinit (
526
+ bases = [],
527
+ body = [],
528
+ decorators = None ,
529
+ doc_node = nodes .Const (value = _type .__doc__ ) if _type .__doc__ else None ,
530
+ )
531
+ builder .object_build (klass , _type )
532
+ astroid_builtin [_type .__name__ ] = klass
509
533
510
534
511
535
_astroid_bootstrapping ()
0 commit comments