@@ -694,12 +694,10 @@ def attr___self__(self):
694694 return self ._instance .bound
695695
696696
697- class GeneratorModel (FunctionModel , ContextManagerModel ):
698- def __init__ (self ):
699- # Append the values from the GeneratorType unto this object.
697+ class GeneratorBaseModel (FunctionModel , ContextManagerModel ):
698+ def __init__ (self , gen_module : nodes .Module ):
700699 super ().__init__ ()
701- generator = AstroidManager ().builtins_module ["generator" ]
702- for name , values in generator .locals .items ():
700+ for name , values in gen_module .locals .items ():
703701 method = values [0 ]
704702 if isinstance (method , nodes .FunctionDef ):
705703 method = bases .BoundMethod (method , _get_bound_node (self ))
@@ -723,21 +721,14 @@ def attr___doc__(self):
723721 )
724722
725723
726- class AsyncGeneratorModel ( GeneratorModel ):
724+ class GeneratorModel ( GeneratorBaseModel ):
727725 def __init__ (self ):
728- # Append the values from the AGeneratorType unto this object.
729- super ().__init__ ()
730- astroid_builtins = AstroidManager ().builtins_module
731- generator = astroid_builtins ["async_generator" ]
732- for name , values in generator .locals .items ():
733- method = values [0 ]
734- if isinstance (method , nodes .FunctionDef ):
735- method = bases .BoundMethod (method , _get_bound_node (self ))
726+ super ().__init__ (AstroidManager ().builtins_module ["generator" ])
736727
737- def patched (cls , meth = method ):
738- return meth
739728
740- setattr (type (self ), IMPL_PREFIX + name , property (patched ))
729+ class AsyncGeneratorModel (GeneratorBaseModel ):
730+ def __init__ (self ):
731+ super ().__init__ (AstroidManager ().builtins_module ["async_generator" ])
741732
742733
743734class InstanceModel (ObjectModel ):
0 commit comments