Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information