Skip to content

Could not resolve manager for abstract model subclasses #1157

@PyB1l

Description

@PyB1l

Bug report

It seem we get an weird behavior on custom manager when subclassing an abstract model defined on another module.

What's wrong

Following the official suggestions I have:

# module A

class MyQuerySet(models.Queryset):
    # my methods

MyManager = models.Manager.from_queryset(MyQuerySet)

class BaseModel(models.Model):
    # model fields
    objects = MyManager()


# On module B

from module_a import BaseModel

class MyModel(BaseModel)
    # more fields

On the initial run and presuming I have no other error everything works fine. With any code change
I get errors Could not resolve manager type for "module_b.MyModel" .

The weird thing is that if I erase the .mypy_cache dir mypy want complain, but again on every code change
the errors get back.

System information

  • OS: Ubuntu 22.04
  • python version: 3.9
  • django version: 4.0
  • mypy version: 0.961
  • django-stubs version: 1.12.0
  • django-stubs-ext version: 0.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmypy-pluginIssues specific to mypy_django_plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions