Repository navigation
Keep explicit None in CallbackData optional fields with a default - #2007
Conversation
pack() writes None as an empty part, but unpack() turned an empty part back into the field default when the default was not None, so the handler got the wrong value. Fixes #2005
|
@claude, review it |
|
Claude finished @JrooTJunior's task in 15s —— View job Review of PR #2007
Verdict: LGTM, with one non-blocking note. What it does
Correctness
TestsThe tests are well targeted. The parametrized test covers Notes (non-blocking)
I didn't run the test suite in this review. The PR reports 2372 passed and |
|
Took the review notes:
Full suite: 2373 passed, ruff clean. |
|
@claude, re-review |
|
Claude finished @JrooTJunior's task in 12s —— View job Re-review of PR #2007Verdict: LGTM. All three notes from the first review are addressed, and I have no new blocking issues.
Follow-ups from the first review
Code (
|
✔️ Changelog found.Thank you for adding a description of the changes |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev-3.x #2007 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 750 787 +37
Lines 16800 17472 +672
==========================================
+ Hits 16800 17472 +672
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Description
pack()writesNoneas an empty part. Butunpack()turned an empty part into the field default whenever the field had one, soPageCallback(page=None)(withpage: int | None = 1) came back aspage=1, and the.filter()handler got the wrong value.Now an empty part becomes
Nonewhen the field type acceptsNone. Other cases stay as they were:""→""(from Fix handling of default empty string ("") in CallbackData filter #1493)None(e.g.foo: int = 1) → the defaultFixes #2005
Type of change
How Has This Been Tested?
test_unpack_explicit_none_with_default(int | None = 1,bool | None = True,str-enum| None,str | None = "experiment",Optional[int] = 1): all 5 cases fail before the fix and pass after. It also checks that the default still round-trips.foo: int = 1still unpacks an empty part as the default.uv run pytest tests: 2372 passed, 52 skipped.make lint: ruff, both mypy passes and pre-commit are clean.Test Configuration:
Checklist: