Utilities/py3flakes/checker.py

branch
5_1_x
changeset 1536
7d766369823d
parent 1510
e75ecf2bd9dd
equal deleted inserted replaced
1533:087aa177764a 1536:7d766369823d
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 2
3 # Copyright (c) 2010 - 2012 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2010 - 2012 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 # Original (c) 2005-2008 Divmod, Inc. 5 # Original (c) 2005-2010 Divmod, Inc.
6 # 6 #
7 # This module is based on pyflakes for Python2 but was heavily hacked to 7 # This module is based on pyflakes for Python2 but was heavily hacked to
8 # work with Python3 8 # work with Python3 and eric5
9 9
10 import builtins 10 import builtins
11 import os.path 11 import os.path
12 import ast 12 import ast
13 13
470 # arguments, but these aren't dispatched through here 470 # arguments, but these aren't dispatched through here
471 raise RuntimeError( 471 raise RuntimeError(
472 "Got impossible expression context: {0:r}".format(node.ctx,)) 472 "Got impossible expression context: {0:r}".format(node.ctx,))
473 473
474 def FUNCTIONDEF(self, node): 474 def FUNCTIONDEF(self, node):
475 if getattr(node, "decorator_list", None) is not None: 475 if hasattr(node, "decorator_list"):
476 for decorator in node.decorator_list: 476 for decorator in node.decorator_list:
477 self.handleNode(decorator, node) 477 self.handleNode(decorator, node)
478 self.addBinding(node.lineno, FunctionDefinition(node.name, node)) 478 self.addBinding(node.lineno, FunctionDefinition(node.name, node))
479 self.LAMBDA(node) 479 self.LAMBDA(node)
480 480
527 """ 527 """
528 Check names used in a class definition, including its decorators, base 528 Check names used in a class definition, including its decorators, base
529 classes, and the body of its definition. Additionally, add its name to 529 classes, and the body of its definition. Additionally, add its name to
530 the current scope. 530 the current scope.
531 """ 531 """
532 if getattr(node, "decorator_list", None) is not None: 532 for decorator in getattr(node, "decorator_list", []):
533 for decorator in node.decorator_list: 533 self.handleNode(decorator, node)
534 self.handleNode(decorator, node)
535 for baseNode in node.bases: 534 for baseNode in node.bases:
536 self.handleNode(baseNode, node) 535 self.handleNode(baseNode, node)
537 self.addBinding(node.lineno, Binding(node.name, node)) 536 self.addBinding(node.lineno, Binding(node.name, node))
538 self.pushClassScope() 537 self.pushClassScope()
539 self.handleBody(node) 538 self.handleBody(node)

eric ide

mercurial