From c07fabdaea2f60b6cf62e5cd7aa66eee715dbe1f Mon Sep 17 00:00:00 2001 From: ProstoMaxim Date: Wed, 10 Aug 2022 16:00:30 +0300 Subject: [PATCH] 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 --- rest_framework/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 3896805177d..052a766cd8a 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -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.' @@ -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'), (