mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Enforce is_valid(raise_exception=False)
as a keyword-only argument. (#7952)
* make raise_exception a keyword-only argument * make raise_exception keyword-only in metaclass
This commit is contained in:
parent
35a6d65e22
commit
791d48c690
|
@ -216,7 +216,7 @@ class BaseSerializer(Field):
|
||||||
|
|
||||||
return self.instance
|
return self.instance
|
||||||
|
|
||||||
def is_valid(self, raise_exception=False):
|
def is_valid(self, *, raise_exception=False):
|
||||||
assert hasattr(self, 'initial_data'), (
|
assert hasattr(self, 'initial_data'), (
|
||||||
'Cannot call `.is_valid()` as no `data=` keyword argument was '
|
'Cannot call `.is_valid()` as no `data=` keyword argument was '
|
||||||
'passed when instantiating the serializer instance.'
|
'passed when instantiating the serializer instance.'
|
||||||
|
@ -735,7 +735,7 @@ class ListSerializer(BaseSerializer):
|
||||||
|
|
||||||
return self.instance
|
return self.instance
|
||||||
|
|
||||||
def is_valid(self, raise_exception=False):
|
def is_valid(self, *, raise_exception=False):
|
||||||
# This implementation is the same as the default,
|
# This implementation is the same as the default,
|
||||||
# except that we use lists, rather than dicts, as the empty case.
|
# except that we use lists, rather than dicts, as the empty case.
|
||||||
assert hasattr(self, 'initial_data'), (
|
assert hasattr(self, 'initial_data'), (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user