fix: treat i2's NotSet signature default as required / no default - #34
Merged
Merged
Conversation
Input elements, input specs, pydantic model specs and argument annotation now read defaults through `front.util.param_default`, which maps i2's `NotSet` sentinel to `Parameter.empty`. So a signature with NotSet defaults (as a re-landed i2mint/i2#88 FuncFactory would show) no longer crashes numeric inputs (`int(NotSet)`), prefills text inputs with "NotSet", or becomes a pydantic default. No-op for current signatures. Uses `i2.is_not_set` when available, else falls back on `i2.deco.NotSet`, so the i2 floor is unchanged. Refs i2mint/i2#48 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ly (review follow-up) The fixture no longer mutates _foo in place (Sig.__call__ sets __signature__ on its argument), so comparisons against the plain signature are meaningful; 6 of 8 tests now fail without the fix. The i2 fallback imports i2.deco.NotSet at import time instead of on every call. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Member
Author
|
Independent refute-review (sub-agent) could not refute the change: pydantic (incl. the field-rename path), crude dispatch and input specs all treat
Accepted as-is (low): a crude-wrapped function called directly (not via the UI) with a missing arg now receives Gate re-run: 72 passed with i2 master and with i2 0.1.73. |
thorwhalen
added a commit
to i2mint/streamlitfront
that referenced
this pull request
Sep 22, 2026
…#13) The legacy spec builders (`infer_type`, `get_func_args_specs`, `page_funcs.*get_func_args_specs`, `get_func_elements_commands`) read defaults through the new `util.signature_defaults(sig)`, which drops params whose default is i2's `NotSet` sentinel. So a signature with NotSet defaults (as a re-landed i2mint/i2#88 FuncFactory would show) gives the same widgets as the plain one. No-op for current signatures. The `mk_app` path goes through front, fixed separately (i2mint/front#34). Uses `i2.is_not_set` when available, else falls back on `i2.deco.NotSet`. Refs i2mint/i2#48 Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Step 2 of the re-land plan in i2mint/i2#48, for
front: treat i2'sNotSetsentinel as a signature default the same way asinspect.Parameter.empty("required, no default").front.util.param_default(param): returnsparam.default, orParameter.emptywhen it isNotSet.InputBase.__post_init__(value prefill),mk_input_element_specs(type inference,is_noneable),func_to_pyd_model_specs(pydantic default),_annotate_func_arguments(annotation from default type).Why
i2mint/i2#88 gave
FuncFactorysignaturesNotSetdefaults and was reverted in i2mint/i2#89, becauseIntInputBase/FloatInputBasecrashed onint(NotSet)andTextInputBasewas prefilled with the text"NotSet". With this PR, front already behaves when #88 is re-applied.No-op against the current i2: no current signature carries
NotSet, soparam_default(p) is p.defaultfor every existing parameter.i2 compatibility (decision)
Uses
i2.is_not_set(added in i2mint/i2#91) when available, otherwise falls back oni2.deco.NotSet(present since 2023). So the i2 floor is not raised. Chosen over declaring a minimum i2 version because the consumer change must work before and after the i2 release, and raising a floor forces every front user to upgrade i2 for a no-op.Tests
tests/test_not_set_defaults.pybuilds_foo's signature withNotSetdefaults (usingi2.deco.NotSet, so it works with any i2) and checks: no crash, no prefill,NotSetnever reaches state; real defaults still prefill; input specs are identical to the plain signature's; pydantic specs mark the params required. 4 of these fail without the fix.Gate
pytest --doctest-modules front tests(scrap/examples ignored), py3.12: 71 passed, with i2 master (hasis_not_set) and with i2 0.1.73 from PyPI (fallback path). Master: 63 passed.ruff check/ruff format --checkon changed files: clean.streamlitfront16 passed (selenium-only modules skipped, not installed),opyratorfront2 passed,extrude3 passed.🤖 Generated with Claude Code