[Python-projects] Suspicious-lambda checker for pylint
Nathaniel Manista
nathaniel at google.com
Sat Jan 24 00:10:30 CET 2009
Ping?
-Nathaniel
On Wed, Dec 17, 2008 at 1:57 PM, Nathaniel Manista <nathaniel at google.com>wrote:
> Sylvain-
>
> On Tue, Dec 16, 2008 at 10:31 AM, Sylvain Thénault <
> sylvain.thenault at logilab.fr> wrote:
>
>> [snip introduction]
>>
>> > I'd like to contribute this code to pylint and am eager to work with
>> > you toward that end - my choice of terms, warning code (W0108), and of
>> > which source file is appropriate for it may need to be corrected, for
>> > example.
>>
>> humm, I would use a [R]efactor code since this message is indeed
>> suggesting a
>> refactoring. Regarding the numbering its fine : the two first number (01
>> here) are for the ckecher which emit the message, while the two last are
>> used
>> to have a unique message id while grouping "similar" messages in
>> subsequent
>> number (though that's not really enforced).
>>
>
> Actually, I think it fits in far better with the [W]arnings than the
> [R]efactorings. The warnings are triggered in cases where the programmer did
> something that they probably didn't intend to do or didn't realize was
> completely unnecessary - "unnecessary pass statement", "unnecessary
> semicolon", "statement seems to have no effect", for example. I think that
> this warning, which could very easily have used the text "lambda seems to
> have no effect" belongs in that group. In contrast the refactorings (such as
> "too many public methods") are generally more about code metrics on the
> scale of modules and classes than about likely errors with individual
> statements or expressions. Under that reasoning, would the designation
> "W0108" work for you?
>
>
>> > I apologize for not submitting it with "hg email" as is suggested
>> > on the pylint web site - I'm still learning my way around the basics of
>> hg.
>> > I also apologize for the lack of a unit test - I could neither find on
>> the
>> > pylint web site instructions for running the existing tests nor figure
>> out
>> > on my own how to run them (and extend them).
>>
>> submitting simple diff is fine as long as the patch is simple and well
>> targeted, as yours. But not having a test is a problem. Pylint has a
>> simple
>> functional test system :
>> * put an input python file into the test/inputs directory
>> * put a file in the test/messages directory named as your python file but
>> with '.txt' instead of '.py', containing expected messages
>> * run the functional tests using "python test_func.py" in the test
>> directory
>>
>> take a look at other test to see how they isolate the message to test and
>> what
>> to put in the message file (take care: message order differs from a bare
>> pylint execution).
>>
>
> I have done this using func_w0101.py and func_w0101.txt as models; please
> find the files func_w0108.py and func_w0108.txt attached to this message.
>
>
>> I would be happy to include your patch once the test are there as well :)
>>
>
> Glad to hear it. Thanks,
> -Nathaniel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.logilab.org/pipermail/python-projects/attachments/20090123/75bf35b7/attachment.htm
More information about the Python-Projects
mailing list