Hi,
Thank you for your feedback, Sylvain. I agree that the root of the
problem lies in the block range.
I attached a new patch that removes the string comparison with a
cleaner instanceof check. Tests are included too.
Thank you,
Alex Margarit
Team Tahiti, U of T
On Mon, Mar 22, 2010 at 3:19 AM, Sylvain Thénault
<[email protected]> wrote:
> On 21 mars 11:33, Alex Margarit wrote:
>> Hey,
>
> Hi,
>
> sorry, I've been missing some time last week to review pylint patches.
> Hopefuly this week will be better :)
>
>> I was wondering if anyone had the time to take a look at the patch I
>> sent for Pylint ticket #8776. Do you think my solution is appropriate?
>>
>> http://www.logilab.org/ticket/8776
>>
>> I reattached the diff. Thanks,
>> diff -r f5f084e5267a ChangeLog
>> diff -r f5f084e5267a lint.py
>> --- a/lint.py Thu Mar 04 12:12:32 2010 +0100
>> +++ b/lint.py Tue Mar 16 01:35:36 2010 -0400
>> @@ -466,7 +466,10 @@
>> self._module_msgs_state[msgid][line] = state
>> except KeyError:
>> self._module_msgs_state[msgid] = {line:
>> state}
>> - del lines[lineno]
>> + # the arguments list is a special case, since it is
>> part of
>> + # the same logical code line as the function definition
>> + if str(node) != 'arguments()':
>> + del lines[lineno]
>
> I don't think this solution is appropriate. First, testing str(node) is
> definitly
> a bad idea. Using isinstance(node, ...) would be e bit better but still sound
> bad.
>
> Actually, the special casing on arguments at this point of the code seems to
> be
> the flaw. IMO the root of the pb lies in values returned by block_range() for
> function
> and / or arguments nodes.
>
> --
> Sylvain Thénault LOGILAB, Paris (France)
> Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
> Développement logiciel sur mesure: http://www.logilab.fr/services
> CubicWeb, the semantic web framework: http://www.cubicweb.org
>
>
diff -r 16f098a0c3ae ChangeLog
--- a/ChangeLog Tue Mar 30 14:54:42 2010 +0200
+++ b/ChangeLog Thu Apr 01 12:18:54 2010 -0400
@@ -1,6 +1,8 @@
ChangeLog for PyLint
====================
--
+ * fix #8776: inline disable-message regression
+
* fix #19498: fix windows batch file
* fix #19339: pylint.el : non existing py-mod-map
diff -r 16f098a0c3ae lint.py
--- a/lint.py Tue Mar 30 14:54:42 2010 +0200
+++ b/lint.py Thu Apr 01 12:18:54 2010 -0400
@@ -460,7 +460,10 @@
self._module_msgs_state[msgid][line] = state
except KeyError:
self._module_msgs_state[msgid] = {line: state}
- del lines[lineno]
+ # the arguments list is a special case, since it is part of
+ # the same logical code line as the function definition
+ if not isinstance(node, nodes.Arguments):
+ del lines[lineno]
# code checking methods ###################################################
diff -r 16f098a0c3ae test/input/func_w0102.py
--- a/test/input/func_w0102.py Tue Mar 30 14:54:42 2010 +0200
+++ b/test/input/func_w0102.py Thu Apr 01 12:18:54 2010 -0400
@@ -65,3 +65,37 @@
"""does not redefine callback returned by with_inner_function_1"""
pass
return callback
+
+def dangerous_default_dict_1(
+ one,
+ two,
+ three = {}
+ ):
+ """three has a dangerous default value"""
+ return three.get(one + two)
+
+def dangerous_default_dict_2(
+ # pylint: disable-msg=W0102
+ one,
+ two,
+ three = {}
+ ):
+ """three has a dangerous default value - warning disabled"""
+ return three.get(one + two)
+
+def dangerous_default_dict_3(
+ one,
+ two,
+ # pylint: disable-msg=W0102
+ three = {}
+ ):
+ """three has a dangerous default value - warning disabled"""
+ return three.get(one + two)
+
+def dangerous_default_dict_4(
+ one,
+ two,
+ three = {}
+ ):
+ """three has a dangerous default value"""
+ return three.get(one + two)
diff -r 16f098a0c3ae test/messages/func_w0102.txt
--- a/test/messages/func_w0102.txt Tue Mar 30 14:54:42 2010 +0200
+++ b/test/messages/func_w0102.txt Thu Apr 01 12:18:54 2010 -0400
@@ -3,3 +3,5 @@
E: 32:func2: function already defined line 29
E: 51:exclusive_func2: function already defined line 45
W: 34:func2: Redefining name '__revision__' from outer scope (line 3)
+W: 69:dangerous_default_dict_1: Dangerous default value {} as argument
+W: 95:dangerous_default_dict_4: Dangerous default value {} as argument
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects