Search code examples
pythondjangopylint

Django forms.ModelForm, Pylint, and new/old style classes


I have a Django 1.5 form that looks like this (simplified):

class BidForm(forms.ModelForm):
    class Meta:
        fields = (
        )
        model = Bid

    def __init__(self, *args, **kwargs):
        super(BidForm, self).__init__(*args, **kwargs)
        something()

When I run Pylint on this, I get a this error:

E1002:<line,row>:BidForm.__init__: Use of super on an old style class

I assume this means the Django's forms.ModelForm is an old-style class and per the python docs my call to super is not happening and is therefore extraneous. Is this true? Can I just delete the super call without effect?


Solution

  • This error/warning has nothing to do with the ModelForm class and has to do with:

        class Meta:
            fields = ()
            model = Bid
    

    You just need to suppress the warning:

        class Meta:  # pylint: disable=C1001
            fields = ()
            model = Bid