[code-quality] This seems like a good warning candidate...
Ian Cordasco
graffatcolmingov at gmail.com
Mon Dec 8 21:21:58 CET 2014
On Mon, Dec 8, 2014 at 2:07 PM, Skip Montanaro <skip.montanaro at gmail.com> wrote:
>
> On Mon, Dec 8, 2014 at 1:32 PM, Phil Frost <indigo at bitglue.com> wrote:
>>
>> Maybe. As a matter of principle, Pyflakes should only emit a warning for
>> things that it is sure is an error.
>
>
> The avoidance of false positives is a noble goal, but given the dynamic
> nature of Python, I'm happy to put up with a few if it means flagging stuff
> that is likely to be an error.
>
> Skip
I'm not sure in what case code like what Skip shared wouldn't result
in an error:
for i in range(1, 10):
for i in ['foo', 'frob', 'bob', 'bogus', 'smogus']:
do_stuff(i)
do_other_stuff(i)
do_other_stuff will probably raise a TypeError if it's expecting an
int instead of a string (and is doing something that cannot be done to
both). I'm fairly confident this will be an error in most cases and
for the people for whom it will be a false positive, it will maybe
teach them to write better loop variable names.
More information about the code-quality
mailing list