mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Refs #23919 -- Replaced kwargs.pop() with keyword-only arguments.
This commit is contained in:
committed by
Tim Graham
parent
0ec4dc91e0
commit
8838d4dd49
@@ -541,9 +541,9 @@ class FileField(Field):
|
||||
'contradiction': _('Please either submit a file or check the clear checkbox, not both.')
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.max_length = kwargs.pop('max_length', None)
|
||||
self.allow_empty_file = kwargs.pop('allow_empty_file', False)
|
||||
def __init__(self, *args, max_length=None, allow_empty_file=False, **kwargs):
|
||||
self.max_length = max_length
|
||||
self.allow_empty_file = allow_empty_file
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def to_python(self, data):
|
||||
@@ -821,9 +821,9 @@ class ChoiceField(Field):
|
||||
|
||||
|
||||
class TypedChoiceField(ChoiceField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.coerce = kwargs.pop('coerce', lambda val: val)
|
||||
self.empty_value = kwargs.pop('empty_value', '')
|
||||
def __init__(self, *args, coerce=lambda val: val, empty_value='', **kwargs):
|
||||
self.coerce = coerce
|
||||
self.empty_value = empty_value
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def _coerce(self, value):
|
||||
@@ -890,8 +890,8 @@ class MultipleChoiceField(ChoiceField):
|
||||
|
||||
|
||||
class TypedMultipleChoiceField(MultipleChoiceField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.coerce = kwargs.pop('coerce', lambda val: val)
|
||||
def __init__(self, *args, coerce=lambda val: val, **kwargs):
|
||||
self.coerce = coerce
|
||||
self.empty_value = kwargs.pop('empty_value', [])
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@@ -971,8 +971,8 @@ class MultiValueField(Field):
|
||||
'incomplete': _('Enter a complete value.'),
|
||||
}
|
||||
|
||||
def __init__(self, fields=(), *args, **kwargs):
|
||||
self.require_all_fields = kwargs.pop('require_all_fields', True)
|
||||
def __init__(self, fields=(), *args, require_all_fields=True, **kwargs):
|
||||
self.require_all_fields = require_all_fields
|
||||
super().__init__(*args, **kwargs)
|
||||
for f in fields:
|
||||
f.error_messages.setdefault('incomplete',
|
||||
@@ -1174,8 +1174,8 @@ class GenericIPAddressField(CharField):
|
||||
class SlugField(CharField):
|
||||
default_validators = [validators.validate_slug]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.allow_unicode = kwargs.pop('allow_unicode', False)
|
||||
def __init__(self, *args, allow_unicode=False, **kwargs):
|
||||
self.allow_unicode = allow_unicode
|
||||
if self.allow_unicode:
|
||||
self.default_validators = [validators.validate_unicode_slug]
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@@ -553,9 +553,9 @@ class BaseModelFormSet(BaseFormSet):
|
||||
unique_fields = set()
|
||||
|
||||
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
|
||||
queryset=None, **kwargs):
|
||||
queryset=None, *, initial=None, **kwargs):
|
||||
self.queryset = queryset
|
||||
self.initial_extra = kwargs.pop('initial', None)
|
||||
self.initial_extra = initial
|
||||
defaults = {'data': data, 'files': files, 'auto_id': auto_id, 'prefix': prefix}
|
||||
defaults.update(kwargs)
|
||||
super().__init__(**defaults)
|
||||
@@ -1065,10 +1065,10 @@ class InlineForeignKeyField(Field):
|
||||
'invalid_choice': _('The inline foreign key did not match the parent instance primary key.'),
|
||||
}
|
||||
|
||||
def __init__(self, parent_instance, *args, **kwargs):
|
||||
def __init__(self, parent_instance, *args, pk_field=False, to_field=None, **kwargs):
|
||||
self.parent_instance = parent_instance
|
||||
self.pk_field = kwargs.pop("pk_field", False)
|
||||
self.to_field = kwargs.pop("to_field", None)
|
||||
self.pk_field = pk_field
|
||||
self.to_field = to_field
|
||||
if self.parent_instance is not None:
|
||||
if self.to_field:
|
||||
kwargs["initial"] = getattr(self.parent_instance, self.to_field)
|
||||
|
||||
Reference in New Issue
Block a user