diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2014-01-22 21:02:13 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-01-22 21:02:13 +0200 |
commit | 20236dc1a9ae84ba55d1ab7db85e81b86a34e295 (patch) | |
tree | 62794c54fcc8e496ea48cff25b251d1ab246a914 /checkers/variables.py | |
parent | 89132cbec80eeea0976f4ab4e8c10d44019bd934 (diff) | |
parent | c16dcb5dc0e6ac28c3b242d67b1d7e761db1c23a (diff) | |
download | pylint-20236dc1a9ae84ba55d1ab7db85e81b86a34e295.tar.gz |
Merged in PCManticore/pylint/nonlocal (pull request #76)
Enhance used-before-assignment check to look for nonlocal uses.
Diffstat (limited to 'checkers/variables.py')
-rw-r--r-- | checkers/variables.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/checkers/variables.py b/checkers/variables.py index 90b7fe7..f461319 100644 --- a/checkers/variables.py +++ b/checkers/variables.py @@ -507,6 +507,12 @@ builtins. Remember that you should avoid to define new builtins when possible.' # defined in global or builtin scope if defframe.root().lookup(name)[1]: maybee0601 = False + else: + # check if we have a nonlocal + if name in defframe.locals: + maybee0601 = not any(isinstance(child, astroid.Nonlocal) + and name in child.names + for child in defframe.get_children()) if (maybee0601 and stmt.fromlineno <= defstmt.fromlineno and not is_defined_before(node) |