Skip to content

Commit 0858421

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3332863 commit 0858421

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

polymorphic/query_translate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
PolymorphicQuerySet support functions
33
"""
44

5-
import copy
65
from collections import deque
76

87
from django.apps import apps
@@ -84,6 +83,7 @@ def _deepcopy_q_object(q):
8483
"""
8584
Make a deepcopy of a Q-object.
8685
"""
86+
8787
def _copy_child(child):
8888
if isinstance(child, tuple):
8989
return child # tuples are immutable, no need to make a copy.
@@ -94,7 +94,7 @@ def _copy_child(child):
9494

9595
children = [_copy_child(c) for c in q.children]
9696

97-
if hasattr(q, 'copy'): # Django 4.2+
97+
if hasattr(q, "copy"): # Django 4.2+
9898
obj = q.copy()
9999
obj.children = children
100100
else:
@@ -114,7 +114,8 @@ def translate_polymorphic_filter_definitions_in_args(queryset_model, args, using
114114
Returns: modified Q objects
115115
"""
116116
return [
117-
translate_polymorphic_Q_object(queryset_model, _deepcopy_q_object(q), using=using) for q in args
117+
translate_polymorphic_Q_object(queryset_model, _deepcopy_q_object(q), using=using)
118+
for q in args
118119
]
119120

120121

polymorphic/tests/test_query_translate.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212

1313
class QueryTranslateTests(TestCase):
14-
1514
def test_translate_with_not_pickleable_query(self):
1615
"""
1716
In some cases, Django may attacha _thread object to the query and we
18-
will get the following when we try to deepcopy inside of
17+
will get the following when we try to deepcopy inside of
1918
translate_polymorphic_filter_definitions_in_args:
2019
2120
TypeError: cannot pickle '_thread.lock' object
@@ -48,6 +47,6 @@ def test_translate_with_not_pickleable_query(self):
4847

4948
# I know this doesn't make sense to pass as a Q(), but
5049
# I haven't found another way to trigger the copy.deepcopy failing.
51-
q = Q(blog__info='blog info') | Q(blog__info=threading.Lock())
50+
q = Q(blog__info="blog info") | Q(blog__info=threading.Lock())
5251

5352
translate_polymorphic_filter_definitions_in_args(Bottom, args=[q])

0 commit comments

Comments
 (0)