help with overwriting __init__ of a form in a formset

I have the following code :

class MyForm(forms.Form) :
...     typ = forms.CharField(required = False)
...     selected = forms.BooleanField(required = False)
...     def __init__(self, *args, **kwargs):
...             super().__init__(*args, **kwargs)
...             self.fields['typ'].widget.attrs['disabled']=True
... 
>>> MyFormSet = forms.formset_factory(MyForm, extra = 0, can_delete = True)
>>> kwargs= {'initial' : [{'typ': 'typ1'}, {'typ':'typ2'}]}
>>> formset = MyFormSet(data = None, files = None, **kwargs)
>>> formset.forms
[<MyForm bound=True, valid=Unknown, fields=(typ;selected;DELETE)>, <MyForm bound=True, valid=Unknown, fields=(typ;selected;DELETE)>]

My forms are bound because the init (self, args, *kwargs) is incorrect? What it the correct definition of init parameters.

You don’t explicitly pass self as a parameter to __init__. In this situation, it’s acting as the data to be bound to the form - that’s why you’re seeing the results you’re showing.

When you call a class method, Python passes self as the first parameter. So in this case, what __init__ is actually getting is self, self, initial=[{'typ': 'typ1'}, {'typ':'typ2'}]

Thanks for the answer. It is a copy error. Of course there is no need to add self in the init. However with correct init the problem remains. In fact after digging more into django code, it seems that in the construct_form in formset, only kwargs are passed. The code below seems to be correct:

class MyForm(forms.Form) :
...     typ = forms.CharField(required = False)
...     selected = forms.BooleanField(required = False)
...     def __init__(self, **kwargs):
...            data = kwargs.pop('data', None)
...            files = kwargs.pop('files', None)
...             super().__init__(data, files, **kwargs)
...             self.fields['typ'].widget.attrs['disabled']=True

However I have not made complete tests.