Skip to content

Commit 4fe05e9

Browse files
Inline homework direct update fields
1 parent 719dbee commit 4fe05e9

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

api/views/homework_upsert_save.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ def apply_homework_data(homework, data):
6666
if error:
6767
return error
6868

69-
apply_homework_direct_fields(homework, data)
69+
for field in HOMEWORK_DIRECT_UPDATE_FIELDS:
70+
if field not in data:
71+
continue
72+
setattr(homework, field, data[field])
7073
return None
7174

7275

@@ -117,10 +120,3 @@ def apply_homework_state(homework, data):
117120

118121
homework.state = data["state"]
119122
return None
120-
121-
122-
def apply_homework_direct_fields(homework, data):
123-
for field in HOMEWORK_DIRECT_UPDATE_FIELDS:
124-
if field not in data:
125-
continue
126-
setattr(homework, field, data[field])

docs/refactoring-plan.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,20 @@ Steps:
20632063
`wide_positional_calls=0`, `wide_function_args=0`,
20642064
`nested_wide_for_unpacking=0`, `range_len_loops=0`), and
20652065
`git diff --check`.
2066+
- [x] 2026-07-02: Removed the single-use homework-upsert direct-field helper.
2067+
The direct update loop now lives in `apply_homework_data` after validated
2068+
fields, keeping text, validated, and direct assignment steps visible in one
2069+
short function. Verification:
2070+
`uv run ruff check api/views/homework_upsert_save.py docs/refactoring-plan.md`,
2071+
`python -m py_compile api/views/homework_upsert_save.py`,
2072+
`uv run python manage.py test api.tests.test_homework_upserts api.tests.test_homework_mutations api.tests.test_homeworks`,
2073+
removed-helper reference scan, touched-function line-threshold scan,
2074+
`uvx pyrefly check`, repository AST cleanup scan excluding migrations
2075+
(`forbidden_comprehensions=0`, `threshold_violations=0`,
2076+
`append_constructed=0`, `wide_tuple_unpacking=0`,
2077+
`wide_positional_calls=0`, `wide_function_args=0`,
2078+
`nested_wide_for_unpacking=0`, `range_len_loops=0`), and
2079+
`git diff --check`.
20662080
- [x] Replace deadline reminder spec factory functions with named static spec
20672081
values and constants so reminder event planning no longer uses trivial
20682082
pass-through factories or nine-field constructor calls. Verification:

0 commit comments

Comments
 (0)