diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2009-03-10 18:30:18 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2009-03-10 18:30:18 +0100 |
commit | da5280f4130a90b36fdf64dfc3dfa58f9b1df54d (patch) | |
tree | ef7b7b55c5f7be2b1e84b57ab6dd2e50a32ed74e | |
parent | 7200bd9d9a59d7944ae489a8ba735f35607e2714 (diff) | |
download | pylint-da5280f4130a90b36fdf64dfc3dfa58f9b1df54d.tar.gz |
little corrections
-rwxr-xr-x | checkers/base.py | 4 | ||||
-rw-r--r-- | checkers/classes.py | 9 | ||||
-rw-r--r-- | test/messages/func_exceptions_raise_type_error.txt | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/checkers/base.py b/checkers/base.py index d6a7edd..43c8868 100755 --- a/checkers/base.py +++ b/checkers/base.py @@ -351,7 +351,7 @@ functions, methods self.add_message('W0105', node=node) return # ignore if this is a function call (can't predicate side effects) - # or a yield (which are wrapped by a discard node in py >= 2.5) + # XXX ? or a yield (which are wrapped by a discard node in _ast) if not any(expr.nodes_of_class((astng.CallFunc, astng.Yield))): self.add_message('W0104', node=node) @@ -445,7 +445,7 @@ functions, methods self.add_message('E0100', node=node) else: values = [r.value for r in returns] - if [v for v in values if not ( + if [v for v in values if not (v is None or (isinstance(v, astng.Const) and v.value is None) or (isinstance(v, astng.Name) and v.name == 'None'))]: self.add_message('E0101', node=node) diff --git a/checkers/classes.py b/checkers/classes.py index 200f5aa..b8b7afc 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -350,15 +350,16 @@ instance attributes.'} # don't care about functions with unknown argument (builtins) if node.args.args is None: return - first = node.argnames()[0] - self._first_attrs.append(first) + first_arg = node.args.args and node.argnames()[0] + self._first_attrs.append(first_arg) + first = self._first_attrs[-1] # static method if node.type == 'staticmethod': - if first in ('self', 'cls', 'mcs'): + if first_arg in ('self', 'cls', 'mcs'): self.add_message('W0211', args=first, node=node) self._first_attrs[-1] = None # class / regular method with no args - elif not first: + elif not node.args.args: self.add_message('E0211', node=node) # metaclass method elif metaclass: diff --git a/test/messages/func_exceptions_raise_type_error.txt b/test/messages/func_exceptions_raise_type_error.txt index 8ac5778..349b9f5 100644 --- a/test/messages/func_exceptions_raise_type_error.txt +++ b/test/messages/func_exceptions_raise_type_error.txt @@ -1,2 +1,2 @@ E: 11: Raising int while only classes, instances or string are allowed -E: 14: Raising None while only classes, instances or string are allowed
\ No newline at end of file +E: 14: Raising NoneType while only classes, instances or string are allowed |