Skip to content

Commit 04c02c8

Browse files
mpasternakclaude
andcommitted
style(forms): use X | Y unions in isinstance (UP038)
ruff v0.6.9 pinned in pre-commit-config still enforces UP038, which my local newer ruff treats as deprecated/off-by-default, so the rule slipped past the local sweep but tripped CI's pre-commit job. Python 3.10+ supports 'isinstance(x, A | B)' natively, and 'requires-python = >=3.10' so this is the canonical form anyway. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 853ab6e commit 04c02c8

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

.claude/scheduled_tasks.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sessionId":"610a2b24-c79a-48e3-b1d3-30d9d64822ea","pid":23539,"procStart":"156828","acquiredAt":1778477032624}

src/formdefaults/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def _serialize(value):
1515
1616
Covers the common Django field types whose `Form.initial` is JSON-able
1717
when snapshotted. For unsupported types, falls back to `str(value)`."""
18-
if value is None or isinstance(value, (bool, int, float, str, list, dict)):
18+
if value is None or isinstance(value, bool | int | float | str | list | dict):
1919
return value
20-
if isinstance(value, (datetime.date, datetime.datetime, datetime.time)):
20+
if isinstance(value, datetime.date | datetime.datetime | datetime.time):
2121
return value.isoformat()
2222
if hasattr(value, "pk"): # ModelChoiceField etc.
2323
return value.pk

0 commit comments

Comments
 (0)