make check more robust

This commit is contained in:
Matthias Mair 2025-10-18 18:41:36 +02:00
parent 631911a872
commit 38c3be4396
No known key found for this signature in database
GPG Key ID: A593429DDA23B66A
1 changed files with 12 additions and 0 deletions

View File

@ -222,6 +222,18 @@ class OutputOptionsMixin:
if getattr(cls, 'output_options', None) is not None:
schema_for_view_output_options(cls)
def __init__(self) -> None:
"""Initialize the mixin. Check that the serializer is compatible."""
super().__init__()
# Check that the serializer was defined
if hasattr(self, 'serializer_class') and (
not issubclass(self.serializer_class, FilterableSerializerMixin)
):
raise Exception(
'INVE-I2: `OutputOptionsMixin` can only be used with serializers that contain the `FilterableSerializerMixin` mixin'
)
def get_serializer(self, *args, **kwargs):
"""Return serializer instance with output options applied."""
if self.output_options and hasattr(self, 'request'):