Skip to content

Commit

Permalink
Enforce is_valid(raise_exception=False) as a keyword-only argument. (
Browse files Browse the repository at this point in the history
…encode#7952)

* make raise_exception a keyword-only argument

* make raise_exception keyword-only in metaclass
  • Loading branch information
ProstoMaxim authored and sigvef committed Dec 3, 2022
1 parent 93db622 commit c07fabd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rest_framework/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def save(self, **kwargs):

return self.instance

def is_valid(self, raise_exception=False):
def is_valid(self, *, raise_exception=False):
assert hasattr(self, 'initial_data'), (
'Cannot call `.is_valid()` as no `data=` keyword argument was '
'passed when instantiating the serializer instance.'
Expand Down Expand Up @@ -735,7 +735,7 @@ def save(self, **kwargs):

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,
# except that we use lists, rather than dicts, as the empty case.
assert hasattr(self, 'initial_data'), (
Expand Down

0 comments on commit c07fabd

Please sign in to comment.