Skip to content

Commit 5e53c53

Browse files
committed
style: Fix py 3.12 quality fixes
1 parent 62e2b88 commit 5e53c53

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/openedx_content/applets/publishing/api.py

Lines changed: 2 additions & 2 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
@@ -854,7 +854,7 @@ 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:
859859
published_obj.publish_log_record = side_effect_change
860860
branch_objs_to_update_with_side_effects.append(published_obj)

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)