-
-
Notifications
You must be signed in to change notification settings - Fork 434
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
default_return_type is Any and hits assertion error for Model.objects.values_list #843
Comments
I can confirm that happens with
For
Using custom manager is not related. All cases where it happened (I commented out first error source to find next one) with me were using related fields: reverse foreign key ( # myapp/models.py
from django.db import models
class Child(models.Model):
name = models.CharField(max_length=10)
class Parent(models.Model):
children = models.ManyToManyField('myapp.Child')
def foo(instance: Parent) -> None:
instance.children.values_list('name', flat=True)
# mre/settings.py
...
INSTALLED_APPS =[..., 'myapp']
...
# ./pyproject.toml
[tool.mypy]
plugins = ["mypy_django_plugin.main"]
ignore_missing_imports = true
disallow_untyped_defs = true
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_any_generics = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_unreachable = true
exclude = [
'migrations/*',
]
[tool.django-stubs]
django_settings_module = "mre.settings" Run |
It's fixed by removing |
@sterliakov thank you for looking into this! Unfortunately I'm not able to reproduce the error with your example. This is what I did:
Did I miss anything? Thanks! |
I'm really confused. I can't reproduce with that setup either, however, it is exactly layout of test project I created. Also I cannot reproduce it with exactly that project (haven't deleted it yet). I have played with versions of |
Rolling back to version |
Hello, I'm trying to debug an issue when evaluating
values_list
and I'm unable to find the root cause or create a minimal example. What is the best way to determine what might be settingsdefault_return_value=Any
?My code is roughly this:
During typechecking I hit the following assertion:
I'm using version
1.9.0
of the stubs with mypy0.931
. I've also tried downgrading to0.910
without any luck. I've also tried usingmaster
for the stubs but this also doesn't address the issue.Here is the minimal example I tried to create but this passes as expected:
Thanks for the help!
The text was updated successfully, but these errors were encountered: