Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve shared manager/queryset method for union #1532

Closed
christianbundy opened this issue Jun 6, 2023 · 2 comments · Fixed by #2027
Closed

Cannot resolve shared manager/queryset method for union #1532

christianbundy opened this issue Jun 6, 2023 · 2 comments · Fixed by #2027
Labels
bug Something isn't working mypy-plugin Issues specific to mypy_django_plugin

Comments

@christianbundy
Copy link
Contributor

Bug report

What's wrong

I have two models with matching managers and querysets, and sometimes use them as a union.

model: type[Foo] | type[Bar]

result = model.objects.shared_method()
Unable to resolve return type of queryset/manager method "shared_method" 

How is that should be

result is inferred as the union of return types of Foo.objects.shared_method() and Bar.objects.shared_method().

System information

  • OS: Docker Linux b5ca85c5b236 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 GNU/Linux
  • python version: 3.11
  • django version: 4.2
  • mypy version: 1.3
  • django-stubs version: 4.2.1
  • django-stubs-ext version: 4.2.1
@christianbundy christianbundy added the bug Something isn't working label Jun 6, 2023
@sobolevn
Copy link
Member

sobolevn commented Jun 6, 2023

PR to the plugin code is welcome!

@flaeppe flaeppe added the mypy-plugin Issues specific to mypy_django_plugin label Sep 8, 2023
@delfick
Copy link
Contributor

delfick commented Mar 23, 2024

@sobolevn good suggestion, #2027 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mypy-plugin Issues specific to mypy_django_plugin
Development

Successfully merging a pull request may close this issue.

4 participants