summaryrefslogtreecommitdiff
path: root/checkers
diff options
context:
space:
mode:
authortmarek <tmarek@google.com>2013-01-08 19:30:22 +0100
committertmarek <tmarek@google.com>2013-01-08 19:30:22 +0100
commit8111a29f0b606367b02704e65678818977ac9cb0 (patch)
tree6f5ecf358b47f6d36281b240592ee5f0ea0a7e1e /checkers
parent72f76bb389d07ceeace16174781f7afa3e90104c (diff)
downloadpylint-8111a29f0b606367b02704e65678818977ac9cb0.tar.gz
Emit a warning if __all__ contains non-string objects.
Closes #112728
Diffstat (limited to 'checkers')
-rw-r--r--checkers/variables.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/checkers/variables.py b/checkers/variables.py
index d094e6c..cf5d9f7 100644
--- a/checkers/variables.py
+++ b/checkers/variables.py
@@ -63,6 +63,9 @@ MSGS = {
'E0603': ('Undefined variable name %r in __all__',
'undefined-all-variable',
'Used when an undefined variable name is referenced in __all__.'),
+ 'E0604': ('Invalid object %r in __all__, must contain only strings',
+ 'invalid-all-object',
+ 'Used when an invalid (non-string) object occurs in __all__.'),
'E0611': ('No name %r in module %r',
'no-name-in-module',
'Used when a name cannot be found in a module.'),
@@ -179,7 +182,8 @@ builtins. Remember that you should avoid to define new builtins when possible.'
except astng.InferenceError:
continue
- if not isinstance(elt_name, astng.Const):
+ if not isinstance(elt_name, astng.Const) or not isinstance(elt_name.value, basestring):
+ self.add_message('E0604', args=elt.as_string(), node=elt)
continue
elt_name = elt.value
# If elt is in not_consumed, remove it from not_consumed