Skip to content

Overriding Meta throws a false alarm in pyright if the parent class defines it too #2723

@Diegovsky

Description

@Diegovsky

Bug report

Say I have the following class:

class BaseModel(models.Model):
    created_at = models.DateTimeField( auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True
        ordering = ["-created_at"]

Inheriting from this base class results in an "Meta" overrides symbol of the same name in class "BaseModel" error.

Workaround

Making Meta inherit from BaseModel.Meta works, but I think this is not very idiomatic, and also makes it compulsory to set abstract = False in all subclasses.

System information

  • OS:
  • python version: 3.12
  • django version: 5.2.3
  • pyright : 1.1.402
  • django-stubs version: 5.2.1
  • django-stubs-ext version: 5.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpyrightRelated to pyright type checker

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions