Skip to content

Cannot resolve manager type when using django-polymorphic #1158

Open
@AntoineRondelet

Description

@AntoineRondelet

Bug report

Hi, I'm not sure if this is a genuine bug or if I am just doing something wrong.
I recently used django-polymorphic to add a new feature in my project and mypy is now breaking. I have plenty of errors:

error: Could not resolve manager type for "<MyModel>.objects"

and

error: Couldn't resolve related manager for relation '<related_name>'

After checking the django polymorphic docs: https://django-polymorphic.readthedocs.io/en/stable/managers.html#manager-inheritance I can see that the manager is inherited. Could that be the source of mypy's troubles here? I feel it could be, but I'd be happy to get opinions.

Is that a known issue with django-polymorphic that I simply am not aware of? If so, is there a (concise) way around it? If not, I'll probably fallback to the "multiple FK in a model" approach to keep mypy running...

Happy to hear if I'm missing something obvious!
Thanks in advance! :)

System information

  • OS: macOS Monterey 12.6
  • python version: 3.10.6
  • django version: 4.1
  • mypy version: 0.971
  • django-stubs version: 1.12.0
  • django-stubs-ext version: 0.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    3rd partyPresence of a third party dependency has been mentionedbugSomething 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