diff options
| author | Vytis Banaitis <vytis.banaitis@gmail.com> | 2017-02-01 18:41:56 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-02-01 11:41:56 -0500 |
| commit | 8838d4dd498c8f66ea4237fe8a79a5f77d6f95c9 (patch) | |
| tree | b75fa27930b8758ad36669b523b084ac09ce290b /django/db/models/query.py | |
| parent | 0ec4dc91e0e7befdd06aa0613b5d0fbe3c785ee7 (diff) | |
Refs #23919 -- Replaced kwargs.pop() with keyword-only arguments.
Diffstat (limited to 'django/db/models/query.py')
| -rw-r--r-- | django/db/models/query.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index dcb1360054..244cfaf164 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -691,11 +691,7 @@ class QuerySet: clone._iterable_class = ValuesIterable return clone - def values_list(self, *fields, **kwargs): - flat = kwargs.pop('flat', False) - if kwargs: - raise TypeError('Unexpected keyword arguments to values_list: %s' % (list(kwargs),)) - + def values_list(self, *fields, flat=False): if flat and len(fields) > 1: raise TypeError("'flat' is not valid when values_list is called with more than one field.") @@ -812,7 +808,7 @@ class QuerySet: else: return self._filter_or_exclude(None, **filter_obj) - def _combinator_query(self, combinator, *other_qs, **kwargs): + def _combinator_query(self, combinator, *other_qs, all=False): # Clone the query to inherit the select list and everything clone = self._clone() # Clear limits and ordering so they can be reapplied @@ -820,18 +816,11 @@ class QuerySet: clone.query.clear_limits() clone.query.combined_queries = (self.query,) + tuple(qs.query for qs in other_qs) clone.query.combinator = combinator - clone.query.combinator_all = kwargs.pop('all', False) + clone.query.combinator_all = all return clone - def union(self, *other_qs, **kwargs): - if kwargs: - unexpected_kwarg = next((k for k in kwargs.keys() if k != 'all'), None) - if unexpected_kwarg: - raise TypeError( - "union() received an unexpected keyword argument '%s'" % - (unexpected_kwarg,) - ) - return self._combinator_query('union', *other_qs, **kwargs) + def union(self, *other_qs, all=False): + return self._combinator_query('union', *other_qs, all=all) def intersection(self, *other_qs): return self._combinator_query('intersection', *other_qs) |
