django-stubs: Could not resolve manager type for "core.models.FooModel.objects" [django-manager-missing]

Bug report

I’ve updated django-stubs-ext from 0.4.0 to 0.5.0 and got a lof of error messages from mypy. Before, mypy didn’t complain

There might actually be nothing wrong with django-stubs, but maybe I need to add a type annotation. The problem is that I have no idea what I need to change.

The code has many unit tests. It’s very unlikely that all of those locations mypy now complains about actually have issues that would prevent proper code execution.

What’s wrong

mypy shows several django-manager-missing errors.

How is that should be

No mypy errors shown

System information

  • OS: Ubuntu
  • python version: 3.8
  • django version: 3.2
  • mypy version: 0.942
  • django-stubs version: 1.12.0
  • django-stubs-ext version: 0.5.0

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 16
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Our case is something like

class UUIDPrimaryKeyAbstractModel(models.Model):
    id = models.UUIDField(primary_key=True, unique=True, default=uuid.uuid4, editable=False)

    class Meta:
        abstract = True


class Foo(UUIDPrimaryKeyAbstractModel):
    pass


class Bar(UUIDPrimaryKeyAbstractModel):
    foo = models.ForeignKey(Foo, on_delete=models.CASCADE)

No django-money.

Then it’s definitely related to https://github.com/typeddjango/django-stubs/pull/993#issuecomment-1155151881 and django-money not exporting types.

I’m afraid it’s not much to do other than ignoring the error until django-money starts to export types. At least as far as I’m aware

Having the same issue as @mschoettle , using django-modeltranslation and getting the django-manager-missing error

I am running into this problem when using django-modeltranslation.

type(Model.objects) returns <class 'modeltranslation.manager.MultilingualManager'>.

Is there any workaround that I could do or is this something that would need to be fixed within django-modeltranslation?

Same issue with django-modeltrans. Ive opened an issue there but I just found this one.

In case it helps, I’ve got a minimal project reproducing the issue with that library: https://github.com/browniebroke/modeltrans-mypy-bug

Hi, I’m also using django-money==3.0.0 and I bump into the same problem. It actually blocks me from updating not only the django-stubs version but the mypy one as well.

Is there any temporary workaround?