﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27919	Decide if attrs (and possibly others) are named or positional parameters in new widget rendering code	Claude Paroz	Tim Graham	"Discussed on IRC:
{{{
claudep: in the new form widget rendering code, we often have attrs=None in signatures, but then passed as positional argument in various calls
claudep: I wonder if this is a good practice
claudep: this can lead to some issues when overriding methods and useing *args, or **kwargs
claudep: thoughts?
MarkusH: claudep: I didn't look at the code, but from what you say I can imagine that leading to issues
}}}

A concrete example:
{{{
class CustomSelect(Select):
    def create_option(self, name, value, label, selected, index, attrs=None, **kwargs):
        if 'somestring' in label:
            if attrs is None:
                attrs = {}
            attrs['disabled'] = True
        return super().create_option(name, value, label, selected, index, attrs=attrs,  **kwargs)
}}}
leads to
{{{
...
  File "".../django/forms/widgets.py"", line 671, in get_context
    context = super(Select, self).get_context(name, value, attrs)
  File "".../django/forms/widgets.py"", line 627, in get_context
    context['widget']['optgroups'] = self.optgroups(name, context['widget']['value'], attrs)
  File "".../django/forms/widgets.py"", line 599, in optgroups
    attrs=attrs,
TypeError: create_option() got multiple values for argument 'attrs'
}}}
"	Bug	closed	Forms	1.11	Release blocker	fixed			Ready for checkin	1	0	0	0	0	0
