Skip to content

reverse relations are not recognized by mypy #2272

@AlexandrVasilchuk

Description

@AlexandrVasilchuk

Bug report

Description

I am facing an issue with django-stubs where reverse relations are not recognized by mypy. Despite trying multiple threads and solutions, including those in the following discussions and issues:

Discussion 2192
Issue 150

The problem persists.

Actual Behavior

mypy raises errors indicating that the reverse relation field is not recognized. Specifically, it cannot resolve the keyword 'proposals' into the field.

Expected Behavior

mypy should recognize the reverse relations between models and not raise errors when these relations are used.

Steps to Reproduce

Define models with ManyToManyField and reverse relations.
Run mypy to check for typing errors.

Снимок экрана 2024-07-24 в 15 43 03
Снимок экрана 2024-07-24 в 15 43 28
Снимок экрана 2024-07-24 в 15 44 04

System information

  • OS:
  • python 3.11.4:
  • django 4.2.7,:
  • mypy "1.10.1":
  • django-stubs "5.0.2":
  • django-stubs-ext "5.0.2":

How can I make mypy recognize the reverse relation between these models? It is also important to mention that the models implement standard objects.

Thank you for your assistance.

Metadata

Metadata

Assignees

No one assigned

    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