django-stubs
django-stubs copied to clipboard
AssertionError on Union with custom QuerySet/Manager
Bug report
What's wrong
Mypy crashes with an assertion error if a variable has a union type of two different, custom querysets. I have a branch with a test case to reproduce the issue here. I haven't had time to look at fixing this yet, but I think it's a simple case of adding support for this case.
Traceback (most recent call last):
File "mypy/checkexpr.py", line 3978, in accept
File "mypy/nodes.py", line 1670, in accept
File "mypy/checkexpr.py", line 2087, in visit_member_expr
File "mypy/checkexpr.py", line 2105, in analyze_ordinary_member_access
File "mypy/checkmember.py", line 130, in analyze_member_access
File "mypy/checkmember.py", line 152, in _analyze_member_access
File "mypy/checkmember.py", line 320, in analyze_union_member_access
File "mypy/checkmember.py", line 147, in _analyze_member_access
File "mypy/checkmember.py", line 231, in analyze_instance_member_access
File "mypy/checkmember.py", line 385, in analyze_member_var_access
File "mypy/checkmember.py", line 614, in analyze_var
File "/Users/sigurd/Developer/django-stubs/mypy_django_plugin/transformers/managers.py", line 114, in resolve_manager_method
assert isinstance(manager_instance, Instance)
How is that should be
It should correctly resolve the type or complain if one of the union types are missing the method. Alternatively it could fall back to Any for now.
System information
- OS:
pythonversion: 3.9.10djangoversion: 3.2.12mypyversion: 0.942django-stubsversion: latest masterdjango-stubs-extversion: latest master