Skip to content

Commit 4d7ee8c

Browse files
Inline homework upsert text fields
1 parent 7e9bc33 commit 4d7ee8c

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

api/views/homework_upsert_save.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ def create_homework_for_upsert(upsert):
5454

5555

5656
def apply_homework_data(homework, data):
57-
apply_homework_text_fields(homework, data)
57+
title = homework_title_from_data(data)
58+
if title is not None:
59+
homework.title = title
60+
61+
if "description" in data:
62+
homework.description = data["description"]
5863

5964
error = apply_homework_validated_fields(homework, data)
6065
if error:
@@ -64,15 +69,6 @@ def apply_homework_data(homework, data):
6469
return None
6570

6671

67-
def apply_homework_text_fields(homework, data):
68-
title = homework_title_from_data(data)
69-
if title is not None:
70-
homework.title = title
71-
72-
if "description" in data:
73-
homework.description = data["description"]
74-
75-
7672
def apply_homework_validated_fields(homework, data):
7773
for apply_field in (
7874
apply_homework_instructions_url,

docs/refactoring-plan.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,20 @@ Steps:
20352035
`wide_positional_calls=0`, `wide_function_args=0`,
20362036
`nested_wide_for_unpacking=0`, `range_len_loops=0`), and
20372037
`git diff --check`.
2038+
- [x] 2026-07-02: Removed the single-use homework-upsert text-field assignment
2039+
helper. The title/name fallback and optional description assignment now live
2040+
directly in `apply_homework_data`, before validated fields and direct update
2041+
fields. Verification:
2042+
`uv run ruff check api/views/homework_upsert_save.py docs/refactoring-plan.md`,
2043+
`python -m py_compile api/views/homework_upsert_save.py`,
2044+
`uv run python manage.py test api.tests.test_homework_upserts api.tests.test_homework_mutations api.tests.test_homeworks`,
2045+
removed-helper reference scan, touched-function line-threshold scan,
2046+
`uvx pyrefly check`, repository AST cleanup scan excluding migrations
2047+
(`forbidden_comprehensions=0`, `threshold_violations=0`,
2048+
`append_constructed=0`, `wide_tuple_unpacking=0`,
2049+
`wide_positional_calls=0`, `wide_function_args=0`,
2050+
`nested_wide_for_unpacking=0`, `range_len_loops=0`), and
2051+
`git diff --check`.
20382052
- [x] Replace deadline reminder spec factory functions with named static spec
20392053
values and constants so reminder event planning no longer uses trivial
20402054
pass-through factories or nine-field constructor calls. Verification:

0 commit comments

Comments
 (0)