Probably for adding other arguments later without braking function signature? I'm with you on this one, though. Using kwargs everywhere it's possible really helps developing using Django. Maybe this is a subject for [email protected].
> On 15 Dec 2016, at 15:39, Alexey Gerasimov <[email protected]> wrote: > > > Why "flat" keyword is accepted that way? Why not just as def > values_list(self, *fields, flat=False)? Because of that I cannot have support > in my IDE (autocomplete) > > def values_list(self, *fields, **kwargs): > flat = kwargs.pop('flat', False) > if kwargs: > raise TypeError('Unexpected keyword arguments to values_list: %s' > % (list(kwargs),)) > > if flat and len(fields) > 1: > raise TypeError("'flat' is not valid when values_list is called > with more than one field.") > > _fields = [] > expressions = {} > > for field in fields: > if hasattr(field, 'resolve_expression'): > field_id = str(id(field)) > expressions[field_id] = field > _fields.append(field_id) > else: > _fields.append(field) > > clone = self._values(*_fields, **expressions) > clone._iterable_class = FlatValuesListIterable if flat else > ValuesListIterable > return clone > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/django-users > <https://groups.google.com/group/django-users>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/237365e6-2566-4ef3-b86a-005487afb5b4%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/237365e6-2566-4ef3-b86a-005487afb5b4%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/97B8E175-30A8-4DD4-AD85-F0A1A50BC1EA%40gmail.com. For more options, visit https://groups.google.com/d/optout.

