Skip to content

Commit 7e5a384

Browse files
Fix import in a loop (tortoise#472)
Co-authored-by: Alexey Tylindus <a.tylindus@gmail.com>
1 parent bcf8a3b commit 7e5a384

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

CONTRIBUTORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Contributors
3434
* Mykola Solodukha ``@TrDex``
3535
* Seo Jiyeon ``jiyeonseo``
3636
* Blake Watters ``blakewatters``
37+
* Alexey Tylindus ``@mirrorrim``
3738

3839
Special Thanks
3940
==============

tortoise/queryset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,13 @@ def annotate(self, **kwargs: Function) -> "QuerySet[MODEL]":
401401
402402
:raises TypeError: Value of kwarg is expected to be a ``Function`` instance.
403403
"""
404+
from tortoise.models import get_filters_for_field
405+
404406
queryset = self._clone()
405407
for key, annotation in kwargs.items():
406408
if not isinstance(annotation, Function):
407409
raise TypeError("value is expected to be Function instance")
408410
queryset._annotations[key] = annotation
409-
from tortoise.models import get_filters_for_field
410-
411411
queryset._custom_filters.update(get_filters_for_field(key, None, key))
412412
return queryset
413413

0 commit comments

Comments
 (0)