[Python-projects] E0101 should be a warning

Barry Scott barry.scott at onelan.co.uk
Wed Nov 22 16:18:40 CET 2006


Michael Foord wrote:
> Barry Scott wrote:
>> E0101, Foo.__init__] Explicit return in __init__
>>
>> Why is this an error? I would have expected this to be a warning as 
>> it a matter of style
>> not correctness.
>>   
> But if it returns anything it is an error.
Agreed. (I suspect that "return" and "return None" are
the same in the ast).
>
> An early return certainly shouldn't be an error.
This is the false positive I see with:

class Foo:
    def __init__( self, x ):
        self.a = 1
        if x > 0:
            return
        self.a = 2

a.py:2: [E0101, Foo.__init__] Explicit return in __init__

Barry



More information about the Python-Projects mailing list