Skip to content

fix: don't prefill or type widgets from i2's NotSet signature default - #13

Merged
thorwhalen merged 1 commit into
masterfrom
not-set-defaults-are-required
Sep 22, 2026
Merged

thorwhalen merged 1 commit into
masterfrom
not-set-defaults-are-required

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

What

Step 2/3 of the re-land plan in i2mint/i2#48, for streamlitfront: don't treat i2's NotSet sentinel as a real default.

  • New streamlitfront.util.signature_defaults(sig): sig.defaults without the params whose default is NotSet.
  • Used by the legacy spec builders that read sig.defaults directly: base.infer_type, base.get_func_args_specs, page_funcs.get_func_args_specs, page_funcs.special_get_func_args_specs, page_funcs.get_func_elements_commands.

The current mk_app path builds widgets through front's elements and pydantic helpers. It is fixed in i2mint/front#34, and streamlitfront's own elements never read obj.default. The independent review of that PR found this legacy path (dispatch_funcs → SimplePageFunc) as the one remaining place where the sentinel would become a widget's value= or its inferred type.

No-op against the current i2: no current signature carries NotSet.

i2 compatibility (decision)

Uses i2.is_not_set (i2 >= 0.1.74, i2mint/i2#91) when available, otherwise falls back on i2.deco.NotSet (present since 2023). The i2 requirement is unchanged.

Tests

streamlitfront/tests/test_not_set_defaults.py: for a NotSet-defaulted foo, infer_type and all three spec builders give the same result as for the plain foo, and there is no value= prefill. Both tests fail without the fix. There is also a doctest on signature_defaults.

Gate

  • pytest --doctest-modules streamlitfront (py3.12, scrap/examples and the two selenium-only modules ignored because selenium is not installed here): 18 passed with i2 master and with i2 0.1.73 (fallback path). Master: 16 passed.
  • ruff check / ruff format --check on changed files: clean.
  • Dependents: extrude, know. know cannot be installed on this box (pyaudio needs system portaudio). extrude is tested below.
  • Hosted CI: see checks.

🤖 Generated with Claude Code

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>
@thorwhalen

Copy link
Copy Markdown
Member Author

Independent refute-review (sub-agent): no blocking bug. Both tests fail without the fix. Normal defaults (None, 0, lists, tuples) give unchanged specs, and no other place in streamlitfront reads signature defaults (pydantic_widgets reads front's model fields).

Its findings, and what I did about them:

@thorwhalen
thorwhalen merged commit 1122f26 into master Sep 22, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the not-set-defaults-are-required branch September 22, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant