diff options
author | sylvain thenault <sylvain.thenault@logilab.fr> | 2009-01-16 10:01:40 +0100 |
---|---|---|
committer | sylvain thenault <sylvain.thenault@logilab.fr> | 2009-01-16 10:01:40 +0100 |
commit | 45694b2338d18291cb3d1931cd0434cab8aa65e6 (patch) | |
tree | f80656c286ed8c7bdc2a64c9238d812ecdf5293c /checkers/variables.py | |
parent | 20ebed73995b005f45fffa2bd8565ea086ad11a7 (diff) | |
download | pylint-45694b2338d18291cb3d1931cd0434cab8aa65e6.tar.gz |
fix #6949: as suggested by m. kiilerich, we should remove __dict__ node added by astng to avoid E0601/E0602 false negative
Diffstat (limited to 'checkers/variables.py')
-rw-r--r-- | checkers/variables.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/checkers/variables.py b/checkers/variables.py index dab949c..a3b1501 100644 --- a/checkers/variables.py +++ b/checkers/variables.py @@ -132,7 +132,14 @@ builtins. Remember that you should avoid to define new builtins when possible.' """visit module : update consumption analysis variable checks globals doesn't overrides builtins """ - self._to_consume = [(copy(node.locals), {}, 'module')] + mlocals = copy(node.locals) + # __dict__ is added to module's locals but not available in module's namespace + # (unlike __doc__, __name__, etc...). But take care __dict__ may be assigned + # somewhere in the module, so remove astng inserted nodes (having None lineno) + mlocals['__dict__'] = [n for n in mlocals['__dict__'] if n.lineno is not None] + if not mlocals['__dict__']: + del mlocals['__dict__'] + self._to_consume = [(mlocals, {}, 'module')] self._vars = [] for name, stmts in node.locals.items(): if name in ('__name__', '__doc__', '__file__', '__path__') \ |