Skip to content

ValuesQuerySet is removed and not available #144

@sobolevn

Description

@sobolevn

I have tried to use ValuesQuerySet that is returned in:

def post_dates_by_author(author_id: int):
    """Returns published blog posts."""
    x = BlogPost.objects.filter(
        author__id=author_id,
    ).values_list('created_at', flat=True)
    reveal_type(x)
    return x

Reproduction link: https://github.com/sobolevn/django_stubs_example/blob/master/server/apps/main/logic/repo.py

Output:

» PYTHONPATH="$PYTHONPATH:$PWD" mypy server
server/apps/main/logic/repo.py:20: note: Revealed type is 'django.db.models.query.ValuesQuerySet[server.apps.main.models.BlogPost, datetime.datetime]'

But, it looks like ValuesQuerySet is removed in 1.9, and there's not such class: https://github.com/django/django/blob/aed89adad54a977829c4f180b036033e031ebcc7/docs/releases/1.9.txt#L1069

So, it is not clear how to annotate your function to return ValuesQuerySet when it is missing from django.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions