django-eav2/eav/decorators.py
Mike b5b576aca5 refactor: apply ruff linter rules and standardize code style
Replace flake8 with ruff and apply consistent linting rules across the entire codebase. Update type annotations, quotation marks, and other style-related changes to comply with the new standards.
2024-09-01 14:57:47 -07:00

26 lines
682 B
Python

"""
This module contains pure wrapper functions used as decorators.
Functions in this module should be simple and not involve complex logic.
"""
def register_eav(**kwargs):
"""
Registers the given model(s) classes and wrapped ``Model`` class with
Django EAV 2::
@register_eav
class Author(models.Model):
pass
"""
from django.db.models import Model
from eav import register
def _model_eav_wrapper(model_class):
if not issubclass(model_class, Model):
raise TypeError("Wrapped class must subclass Model.")
register(model_class, **kwargs)
return model_class
return _model_eav_wrapper