diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-01-11 12:01:19 +0200 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-01-11 12:01:19 +0200 |
commit | eaf6aeb50f5bee0364bbac8aef557083dd34e37d (patch) | |
tree | 5ee87904ff6b3872c868d1b3f97bd5bbb38e9781 | |
parent | 255d5c41d34cbb5d2d076b2beab2c81b47531253 (diff) | |
download | pylint-eaf6aeb50f5bee0364bbac8aef557083dd34e37d.tar.gz |
Add the method names for the 'signature-differs' and 'argument-differs'
warnings.
Closes issue #433.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | checkers/classes.py | 12 | ||||
-rw-r--r-- | test/messages/func_interfaces.txt | 2 | ||||
-rw-r--r-- | test/messages/func_w0205.txt | 2 |
4 files changed, 13 insertions, 6 deletions
@@ -34,6 +34,9 @@ ChangeLog for Pylint * Add a new JSON reporter, usable through -f flag. + * Add the method names for the 'signature-differs' and 'argument-differs' + warnings. Closes issue #433. + 2014-11-23 -- 1.4.0 diff --git a/checkers/classes.py b/checkers/classes.py index 7b216fe..1a10c35 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -179,11 +179,11 @@ MSGS = { 'missing-interface-method', 'Used when a method declared in an interface is missing from a \ class implementing this interface'), - 'W0221': ('Arguments number differs from %s method', + 'W0221': ('Arguments number differs from %s %r method', 'arguments-differ', 'Used when a method has a different number of arguments than in \ the implemented interface or in an overridden method.'), - 'W0222': ('Signature differs from %s method', + 'W0222': ('Signature differs from %s %r method', 'signature-differs', 'Used when a method signature is different than in the \ implemented interface or in an overridden method.'), @@ -939,9 +939,13 @@ a metaclass class method.'} if is_attr_private(method1.name): return if len(method1.args.args) != len(refmethod.args.args): - self.add_message('arguments-differ', args=class_type, node=method1) + self.add_message('arguments-differ', + args=(class_type, method1.name), + node=method1) elif len(method1.args.defaults) < len(refmethod.args.defaults): - self.add_message('signature-differs', args=class_type, node=method1) + self.add_message('signature-differs', + args=(class_type, method1.name), + node=method1) def is_first_attr(self, node): """Check that attribute lookup name use first attribute variable name diff --git a/test/messages/func_interfaces.txt b/test/messages/func_interfaces.txt index 3b444d7..a4cd21d 100644 --- a/test/messages/func_interfaces.txt +++ b/test/messages/func_interfaces.txt @@ -3,4 +3,4 @@ E: 77:InterfaceCantBeFound: Undefined variable 'undefined' E: 88:InterfaceCanNowBeFound: Missing method 'troc' from IMachin interface E: 88:InterfaceCanNowBeFound: Missing method 'truc' from IMachin interface F: 77:InterfaceCantBeFound: failed to resolve interfaces implemented by InterfaceCantBeFound (undefined) -W: 71:BadArgument.troc: Arguments number differs from IMachin interface method +W: 71:BadArgument.troc: Arguments number differs from IMachin interface 'troc' method diff --git a/test/messages/func_w0205.txt b/test/messages/func_w0205.txt index 4b36dab..83ac5de 100644 --- a/test/messages/func_w0205.txt +++ b/test/messages/func_w0205.txt @@ -1,2 +1,2 @@ -W: 22:Cdef.abcd: Signature differs from overridden method +W: 22:Cdef.abcd: Signature differs from overridden 'abcd' method |