Instead of using Literal types, overload QuerySet.values_list in the plugin. Fixes #43. (#44)

- Add a couple of extra type checks that Django makes:
  1) 'flat' and 'named' can't be used together.
  2) 'flat' is not valid when values_list is called with more than one field.
This commit is contained in:
Seth Yastrov
2019-03-13 20:10:37 +01:00
committed by Maxim Kurnikov
parent 7c57143310
commit b1a04d2f7d
3 changed files with 41 additions and 11 deletions

View File

@@ -13,6 +13,8 @@ class BlogQuerySet(models.QuerySet[Blog]):
blog_qs: models.QuerySet[Blog]
reveal_type(blog_qs) # E: Revealed type is 'django.db.models.query.QuerySet[main.Blog, main.Blog]'
Blog.objects.values_list('id', flat=True, named=True) # E: 'flat' and 'named' can't be used together.
Blog.objects.values_list('id', 'extra_arg', flat=True) # E: 'flat' is not valid when values_list is called with more than one field.
reveal_type(Blog.objects.in_bulk([1])) # E: Revealed type is 'builtins.dict[Any, main.Blog*]'
reveal_type(Blog.objects.in_bulk()) # E: Revealed type is 'builtins.dict[Any, main.Blog*]'