Skip to content

Commit cb3f179

Browse files
chore: fix quality
1 parent f522df0 commit cb3f179

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/openedx_tagging/models/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def descendant_count(self) -> int:
173173
).count()
174174
return 0
175175

176-
def save(self, *args, **kwargs):
176+
def save(self, *args, **kwargs) -> None:
177177
"""
178178
Compute and persist depth and lineage before saving, then cascade any changes to descendants.
179179
"""
@@ -187,8 +187,8 @@ def save(self, *args, **kwargs):
187187
self.lineage = self.value + "\t"
188188
else:
189189
if Tag.parent.is_cached(self): # pylint: disable=no-member
190-
parent_depth = self.parent.depth
191-
parent_lineage = self.parent.lineage
190+
parent_depth = self.parent.depth # type: ignore[union-attr]
191+
parent_lineage = self.parent.lineage # type: ignore[union-attr]
192192
else:
193193
parent_vals = Tag.objects.values("depth", "lineage").get(pk=self.parent_id)
194194
parent_depth = parent_vals["depth"]
@@ -216,7 +216,9 @@ def save(self, *args, **kwargs):
216216
}
217217
if depth_delta != 0:
218218
update_kwargs["depth"] = F("depth") + depth_delta
219-
self.taxonomy.tag_set.filter(lineage__startswith=old_values["lineage"]).exclude(pk=self.pk).update(
219+
self.taxonomy.tag_set.filter( # type: ignore[union-attr]
220+
lineage__startswith=old_values["lineage"]
221+
).exclude(pk=self.pk).update(
220222
**update_kwargs
221223
)
222224

@@ -602,7 +604,7 @@ def _get_filtered_tags_deep(
602604
.order_by()
603605
.annotate(count=models.Func(F("id"), function="Count"))
604606
)
605-
qs = initial_qs.annotate(child_count=models.Subquery(child_count_sq.values("count")))
607+
qs = initial_qs.annotate(child_count=models.Subquery(child_count_sq.values("count"))) # type: ignore[no-redef]
606608

607609
# Add the parent value
608610
qs = qs.annotate(parent_value=F("parent__value"))

0 commit comments

Comments
 (0)