Files
django-stubs/mypy_django_plugin
Rob Percival 9938378e94 Make AddRelatedManagers look for "objects" on parent model (#730)
* Add failing test for relation to model inheriting `objects`

Fails with:
```
pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output:
Expected:
  main:2: note: Revealed type is "myapp.models.MyUser*"
  main:3: note: Revealed type is "myapp.models.MyUser*"
  <45 (diff)
  <45 (diff)
Actual:
  main:2: note: Revealed type is "myapp.models.MyUser*"
  main:3: note: Revealed type is "myapp.models.MyUser*"
  main:6: error: "MyUser" has no attribute "book_set" (diff)
  main:6: note: Revealed type is "Any"          (diff)
  main:7: error: "MyUser" has no attribute "article_set" (diff)
  main:7: note: Revealed type is "Any"          (diff)
```

* Make AddRelatedManagers look for "objects" on parent model

Previously, AddRelatedManagers would fail if a related model had inherited
its `objects` field from a parent class. This would result in missing
relation attributes. This is fixed by using `get()` instead of `names`;
the former searches the MRO for the symbol, whereas the latter only looks
for symbols declared directly on the class.
2021-10-19 14:31:14 +03:00
..
2019-07-24 13:38:49 +03:00