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 |
483 # arguments, but these aren't dispatched through here |
483 # arguments, but these aren't dispatched through here |
484 raise RuntimeError( |
484 raise RuntimeError( |
485 "Got impossible expression context: {0:r}".format(node.ctx,)) |
485 "Got impossible expression context: {0:r}".format(node.ctx,)) |
486 |
486 |
487 def FUNCTIONDEF(self, node): |
487 def FUNCTIONDEF(self, node): |
488 if getattr(node, "decorator_list", None) is not None: |
488 if hasattr(node, "decorator_list"): |
489 for decorator in node.decorator_list: |
489 for decorator in node.decorator_list: |
490 self.handleNode(decorator, node) |
490 self.handleNode(decorator, node) |
491 self.addBinding(node.lineno, FunctionDefinition(node.name, node)) |
491 self.addBinding(node.lineno, FunctionDefinition(node.name, node)) |
492 self.LAMBDA(node) |
492 self.LAMBDA(node) |
493 |
493 |
540 """ |
540 """ |
541 Check names used in a class definition, including its decorators, base |
541 Check names used in a class definition, including its decorators, base |
542 classes, and the body of its definition. Additionally, add its name to |
542 classes, and the body of its definition. Additionally, add its name to |
543 the current scope. |
543 the current scope. |
544 """ |
544 """ |
545 if getattr(node, "decorator_list", None) is not None: |
545 for decorator in getattr(node, "decorator_list", []): |
546 for decorator in node.decorator_list: |
546 self.handleNode(decorator, node) |
547 self.handleNode(decorator, node) |
|
548 for baseNode in node.bases: |
547 for baseNode in node.bases: |
549 self.handleNode(baseNode, node) |
548 self.handleNode(baseNode, node) |
550 self.addBinding(node.lineno, Binding(node.name, node)) |
549 self.addBinding(node.lineno, Binding(node.name, node)) |
551 self.pushClassScope() |
550 self.pushClassScope() |
552 self.handleBody(node) |
551 self.handleBody(node) |