Skip to content

[flake8-django] DJ001 is not raised for models not directly inherited from Model #2892

@konysko

Description

@konysko

DJ001 is not raised for models which doesn't directly inherits from django.db.models.Model. The source of bug is in https://github.com/charliermarsh/ruff/blob/f7515739acc0a7b5c580bf05aac6055181739c65/crates/ruff/src/rules/flake8_django/rules/helpers.rs#L6 It should lookup whole mro for the Model class.

Affected version: 0.0.246
Snippet reproducing bug:

from django.db import models
from django.utils.translation import gettext_lazy as _
from utils.models import BaseModel


class ExampleModel(BaseModel):
    name = models.CharField(max_length=255, verbose_name=_('Name'), null=True)
    description = models.TextField(verbose_name=_('Description'))

    def __str__(self) -> str:
        return self.name

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions