@@ -694,12 +694,10 @@ def attr___self__(self):
694
694
return self ._instance .bound
695
695
696
696
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 ):
700
699
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 ():
703
701
method = values [0 ]
704
702
if isinstance (method , nodes .FunctionDef ):
705
703
method = bases .BoundMethod (method , _get_bound_node (self ))
@@ -723,21 +721,14 @@ def attr___doc__(self):
723
721
)
724
722
725
723
726
- class AsyncGeneratorModel ( GeneratorModel ):
724
+ class GeneratorModel ( GeneratorBaseModel ):
727
725
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" ])
736
727
737
- def patched (cls , meth = method ):
738
- return meth
739
728
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" ])
741
732
742
733
743
734
class InstanceModel (ObjectModel ):
0 commit comments