diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2014-07-25 15:27:19 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2014-07-25 15:27:19 +0200 |
commit | abdb701148386536b3af783056045550bd6a97a3 (patch) | |
tree | 215b43220020d3c44fa69f2b43629137f7bba9ae /checkers/classes.py | |
parent | 93da77dd6fa68b99cf9566de259fadd843255b69 (diff) | |
download | pylint-abdb701148386536b3af783056045550bd6a97a3.tar.gz |
Only emit attribute-defined-outside-init for definition within the same module as the offended class
This avoids mangling the output in some cases
Diffstat (limited to 'checkers/classes.py')
-rw-r--r-- | checkers/classes.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/checkers/classes.py b/checkers/classes.py index 6d9b2df..170bb19 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -272,9 +272,13 @@ a metaclass class method.'} if not self.linter.is_message_enabled('attribute-defined-outside-init'): return defining_methods = self.config.defining_attr_methods + current_module = cnode.root() for attr, nodes in cnode.instance_attrs.iteritems(): + # skip nodes which are not in the current module and it may screw up + # the output, while it's not worth it nodes = [n for n in nodes if not - isinstance(n.statement(), (astroid.Delete, astroid.AugAssign))] + isinstance(n.statement(), (astroid.Delete, astroid.AugAssign)) + and n.root() is current_module] if not nodes: continue # error detected by typechecking # check if any method attr is defined in is a defining method |