Demo entry 6745692

classPyFlakesResult(HiddenResult):def__init__(self,origin,deadScopes,pyflakes_messages):Result.__init__(self,origin,message='')self.module_scope=self.get_scopes(ModuleScope,deadScopes)[0]self.class_scopes=self.get_scopes(ClassScope,deadScopes)self.function_scopes=self.get_scopes(FunctionScope,deadScopes)self.generator_scopes=self.get_scopes(GeneratorScope,deadScopes)self.doctest_scopes=self.get_scopes(DoctestScope,deadScopes)self.pyflakes_messages=pyflakes_messagesdefget_scopes(self,scope_type,scopes):returnlist(filter(lambdascope:isinstance(scope,scope_type),scopes))defget_nodes(self,scope,node_type):for_,nodeinscope.items():ifisinstance(node,node_type):yieldnodeclassPyFlakesASTBear(LocalBear):AUTHORS={'The coala developers'}AUTHORS_EMAILS={'coala-devel@googlegroups.com'}LICENSE='AGPL-3.0'defrun(self,filename,file):""" Generates pyflakes-enhance-AST for the input file and returns deadScopes as HiddenResult :return: One HiddenResult containing a dictionary with keys being type of scope and values being a list of scopes generated from the file. """tree=ast.parse(''.join(file))result=Checker(tree,filename=filename,withDoctest=True)yieldPyFlakesResult(self,result.deadScopes,result.messages)