Skip to content

Commit 6cf91a5

Browse files
committed
style: Fix py 3.12 quality fixes
1 parent 62e2b88 commit 6cf91a5

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/openedx_content/applets/publishing/api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from contextlib import nullcontext
1111
from datetime import datetime, timezone
12-
from typing import ContextManager, Optional
12+
from typing import ContextManager, Optional, cast
1313

1414
from django.core.exceptions import ObjectDoesNotExist
1515
from django.db.models import F, Prefetch, Q, QuerySet
@@ -824,7 +824,7 @@ def _create_side_effects_for_change_log(change_log: DraftChangeLog | PublishLog)
824824
# "This Unit's version stayed the same, but its dependency hash changed
825825
# because a child Component's draft version was changed." We gather them
826826
# all up in a list so we can do a bulk_update on them.
827-
branch_objs_to_update_with_side_effects = []
827+
branch_objs_to_update_with_side_effects: list[Draft | Published] = []
828828

829829
while changes_and_affected:
830830
change, affected = changes_and_affected.pop()
@@ -854,9 +854,11 @@ def _create_side_effects_for_change_log(change_log: DraftChangeLog | PublishLog)
854854
# Update the current branch pointer (Draft or Published) for this
855855
# entity to point to the side_effect_change (if it's not already).
856856
if branch_cls == Published:
857-
published_obj = affected # 'affected' is the current Published object
857+
published_obj = cast(Published, affected)
858858
if published_obj.publish_log_record_id != side_effect_change.pk:
859-
published_obj.publish_log_record = side_effect_change
859+
published_obj.publish_log_record = cast(
860+
PublishLogRecord, side_effect_change
861+
)
860862
branch_objs_to_update_with_side_effects.append(published_obj)
861863
elif branch_cls == Draft:
862864
draft_obj = affected # 'affected' is the current Draft object

src/openedx_django_lib/fields.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import hashlib
1414
import uuid
15+
from typing import Any
1516

1617
from django.db import models
1718

@@ -124,7 +125,7 @@ def key_field(**kwargs) -> MultiCollationCharField:
124125
return case_sensitive_char_field(max_length=500, blank=False, **kwargs)
125126

126127

127-
def hash_field(**kwargs) -> models.CharField:
128+
def hash_field(**kwargs: Any) -> models.CharField:
128129
"""
129130
Holds a hash digest meant to identify a piece of content.
130131
@@ -145,13 +146,14 @@ def hash_field(**kwargs) -> models.CharField:
145146
didn't seem worthwhile, particularly the possibility of case-sensitivity
146147
related bugs.
147148
"""
148-
default_kwargs = {
149+
default_kwargs: dict[str, Any] = {
149150
"max_length": 40,
150151
"blank": False,
151152
"null": False,
152153
"editable": False,
153154
}
154-
return models.CharField(**(default_kwargs | kwargs))
155+
merged: dict[str, Any] = {**default_kwargs, **kwargs}
156+
return models.CharField(**merged)
155157

156158

157159
def manual_date_time_field() -> models.DateTimeField:

0 commit comments

Comments
 (0)