summaryrefslogtreecommitdiff
path: root/checkers
diff options
context:
space:
mode:
authorcpopa <devnull@localhost>2014-01-22 21:10:22 +0200
committercpopa <devnull@localhost>2014-01-22 21:10:22 +0200
commit86a66977a8a5537ed99d8c164f6ba34554d3d3f2 (patch)
tree1045b45d4dcd737464cf3ecfe34ffb5f9a16d2ba /checkers
parent20236dc1a9ae84ba55d1ab7db85e81b86a34e295 (diff)
parent6158e88a3684aa67215ba809cbb7890a73b057d9 (diff)
downloadpylint-86a66977a8a5537ed99d8c164f6ba34554d3d3f2.tar.gz
Merge with default.
Diffstat (limited to 'checkers')
-rw-r--r--checkers/variables.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/checkers/variables.py b/checkers/variables.py
index f461319..9e8169f 100644
--- a/checkers/variables.py
+++ b/checkers/variables.py
@@ -15,13 +15,15 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""variables checkers for Python code
"""
-
+import os
import sys
from copy import copy
import astroid
from astroid import are_exclusive, builtin_lookup, AstroidBuildingException
+from logilab.common.modutils import load_module_from_name
+
from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker
from pylint.checkers.utils import (PYMETHODS, is_ancestor_name, is_builtin,
@@ -217,7 +219,25 @@ builtins. Remember that you should avoid to define new builtins when possible.'
del not_consumed[elt_name]
continue
if elt_name not in node.locals:
- self.add_message('E0603', args=elt_name, node=elt)
+ if not node.package:
+ self.add_message('undefined-all-variable',
+ args=elt_name,
+ node=elt)
+ else:
+ basename = os.path.splitext(node.file)[0]
+ if os.path.basename(basename) == '__init__':
+ name = node.name + "." + elt_name
+ try:
+ load_module_from_name(name)
+ except ImportError:
+ self.add_message('undefined-all-variable',
+ args=elt_name,
+ node=elt)
+ except SyntaxError as exc:
+ # don't yield an syntax-error warning,
+ # because it will be later yielded
+ # when the file will be checked
+ pass
# don't check unused imports in __init__ files
if not self.config.init_import and node.package:
return