Q:

build_attrs() got an unexpected keyword argument 'type'

I am using django framework and trying to integrate a paypal payment gateway.  But I am getting this error
build_attrs() got an unexpected keyword argument 'type'

Django Version: 1.11.11
Python Version: 3.6.3
Exception Value: build_attrs() got an unexpected keyword argument 'type'
Exception Location: /home/iuser/anaconda3/lib/python3.6/site-packages/paypal/standard/widgets.py in render, line 35
from django import forms
try:
    from django.forms.utils import flatatt # Django 1.7 and later
except ImportError:
    from django.forms.util import flatatt # earlier

from django.utils.safestring import mark_safe
from django.utils.encoding import force_text

class ValueHiddenInput(forms. HiddenInput):
    """
    Widget that renders only if it has a value. 
    Used to remove unused fields from PayPal buttons. 
    """

    def render(self, name, value, attrs=None):
        if value is None:
            return u''
        else:
            return super(ValueHiddenInput, self).render(name, value, attrs)

class ReservedValueHiddenInput(ValueHiddenInput):
    """
    Overrides the default name attribute of the form. 
    Used for the PayPal `return` field. 
    """

    def render(self, name, value, attrs=None):
        if value is None:
            value = ''
        final_attrs = self.build_attrs(attrs, type=self.input_type)
        if value ! = '':
            final_attrs['value'] = force_text(value)
        return mark_safe(u'<input%s />' % flatatt(final_attrs))

A:

In django-1.11 the build_attrs function has been changed as specified in the release notes [Django-doc]:

The signature of private API Widget.build_attrs() changed from extra_attrs=None, **kwargs to base_attrs, extra_attrs=None. 

You need to change the call to:
class ReservedValueHiddenInput(ValueHiddenInput):
    """
    Overrides the default name attribute of the form. 
    Used for the PayPal `return` field. 
    """

    def render(self, name, value, attrs=None):
        if value is None:
            value = ''
        final_attrs = self.build_attrs(attrs, {'type': self.input_type})
        if value ! = '':
            final_attrs['value'] = force_text(value)
        return mark_safe(u'<input%s />' % flatatt(final_attrs))

