Skip to content

The numeric-range ratchet test does not run on Typer 0.29 (it reads param.type and plants click_type=) #1609

Open

Description

@markramm

Filed by the maintainer's conductor agent (automated). Reproduced on the head of #1604 (63d61235, which is dev f0b010ad plus the #1597 fix) in a fresh environment with Typer 0.29.1. Written so someone new to Pyrite can take it from this issue alone.

What happens

pyproject.toml allows any Typer from 0.12.3 up; the lock (and so CI) installs 0.27.3. After #1597 is fixed, the command lines run on Typer 0.29.1, but one test file does not:

$ pytest tests/test_cli_numeric_options_declare_a_range.py -n0 -q      # Typer 0.29.1
33 failed, 5 passed
  • 28 × AttributeError: 'TyperOption' object has no attribute 'type'. The checker's helpers read param.type (lines 182, 213, 214, 542, 669, 717). In Typer 0.29.1, typer.core.TyperOption has no type; the attributes it does have that mention a type are bare_type, _bare_type, display_type, display_type_rich and param_type_name.
  • 5 × TypeError: Option() got an unexpected keyword argument 'click_type'. These are apps the test file plants itself (for example test_planted_typer_parser_or_click_type_cannot_be_classified[click_type=INT]). Typer 0.29 removed the keyword.

On Typer 0.27.3 the same file passes (38 tests).

No production code is involved: nothing under pyrite/ or extensions/ reads param.type (grep), and the commands themselves run on 0.29.1.

Why it matters

  • This file is the ratchet for Every numeric CLI option declares its range, and a test says so #1541 (every numeric CLI option declares its range). On Typer 0.29 it checks nothing, so the day the lock moves to 0.29 the ratchet is gone, and with it the test every per-option range pull request relies on.
  • .github/workflows/unlocked.yml runs the suite on the newest allowed versions every Monday. Its next run will show these 33 failures.

Reproduce

uv venv /tmp/t029 && uv pip install --python /tmp/t029/bin/python -e ".[cli,dev]" "typer==0.29.1"
for e in extensions/*/; do uv pip install --python /tmp/t029/bin/python -e "$e"; done
/tmp/t029/bin/python -m pytest tests/test_cli_numeric_options_declare_a_range.py -n0 -q

(Do this in a throwaway environment; do not change uv.lock or the repo's .venv.)

Invariant

The range checker classifies every command-line parameter (numeric and bounded, numeric and unbounded, not numeric, or cannot tell) on every Typer version pyproject.toml allows, and its planted controls go red on each of them.

Not yet groomed: one question is open

What does Typer 0.29 expose that says "this parameter is an int or a float, with this min and max"? The fix depends on the answer:

  • (a) if bare_type plus the option's min/max carry it, the helpers read the number type and the range through one small function that works on both versions, and the planted click_type= cases run only where the keyword exists (they pin a Typer 0.27 behaviour);
  • (b) if 0.29 does not expose the range at all, say so in the test's docstring as a stated limit and decide whether the lock, or the allowed range in pyproject.toml, stays below 0.29 until it does.

A first step that needs no decision: print vars(param) for one bounded and one unbounded numeric option on 0.27.3 and on 0.29.1 and put both in a comment here.

Acceptance (once the question is answered)

- On Typer 0.27.3 and on 0.29.1: tests/test_cli_numeric_options_declare_a_range.py passes, with the same number of
  parameters classified on both (print the counts in the pull request).
- A planted unbounded numeric option is reported on both versions (the planted tests are red without the checker).
- No `skip` that hides the whole file on a Typer version.
Out of scope: moving the lock to Typer 0.29; a CI job on the newest Typer (unlocked.yml already runs weekly).

Found while reviewing #1604 (the worker's report lists it under "Left"); related: #1597, #1541.

Activity

  1. added
    bugSomething isn't working
    cliCommand-line interface
    qualityRefactoring, test refactoring, code health
    on Nov 17, 2026
  2. added this to the 0.26.4 milestone on Nov 17, 2026
  3. markramm commented on Nov 17, 2026

    @markramm
    CollaboratorAuthor

    Automated groom by the maintainer's conductor agent.

    Groom 2026-11-17

    Model. The user's model: "the ratchet for #1541 goes red when I add a numeric CLI option with no range, whichever Typer I have". The implementation model: the checker reads one thing from each click parameter (its value type) and judges it by class name and by calling the type's own convert; the only version-dependent step is how it gets that type from a parameter. Today it assumes param.type exists. On Typer 0.29.1 it does not, so the ratchet checks nothing there (33 of 38 tests error).

    1. Contracts that apply

    2. What the code does today (dev d4fcea8)

    Everything version-dependent is in one file, tests/test_cli_numeric_options_declare_a_range.py:

    • numeric_params line 182: _numeric_members(param.type).
    • unclassified_params lines 213-214: _members(param.type) and type(param.type).__name__.
    • test_count_option_is_excluded... line 531: getattr(param.type, "min", None).
    • test_typer_gives_a_func_param_type... line 658 (p.type) and the test near line 704-706 (.type then convert).
    • Planted apps use typer.Option(..., click_type=...) at lines 633-635 and 650; Typer 0.29 raises TypeError: Option() got an unexpected keyword argument 'click_type'. These pin 0.27 behaviour (FuncParamType for parser=/click_type=). parser=int (line 625) still exists in 0.29.
    • Docstring lines 53 and 205-206 say "locked Typer 0.27.3".
      No production file reads param.type (issue says grep found none; unchecked by me).
      Reproduce (throwaway env, do not touch the repo .venv): the commands in the issue body. Result on 0.29.1: 33 failed, 5 passed; on 0.27.3: 38 pass. I did not run it; the counts are the issue's.

    3. Invariant and surfaces

    Invariant: the checker classifies every parameter (numeric bounded, numeric unbounded, not numeric, cannot tell) on every Typer version the project allows, and its planted controls are red on each.

    • Surface: one test file only. Not CLI, REST, MCP, plugins, shipped schemas or on-disk files.
    • Enumeration source: the parameters of the click tree built from the three root apps (registry()); the version-dependent reads are the six .type sites above, found by grep -n '\.type\b\|click_type\|bare_type' on the file.
      Shapes (counted by that grep): 6 reads of param.type; 5 planted parametrizations/apps using click_type= (lines 626, 633-635, 650, one test id each); 1 hard-coded FuncParamType pin.

    4. Options

    A. One adapter, _value_type(param), that returns param.type where present and otherwise the equivalent from 0.29, and replace the six reads. Run the click_type= plants only where typer.Option accepts the keyword (check with inspect.signature), and add a parser= plant that runs on both. Smallest change; keeps the behavioural check.
    B. Cap Typer below 0.29 in pyproject.toml. Contradicts #1597 (the CLI now imports on 0.29) and hides the next break. Not recommended.
    C. Rebuild the checker on Typer's own typer.main introspection instead of click params. Larger; no evidence it is needed.
    Recommendation: A.

    5. Open questions (worker: overturn with evidence)

    • What does a 0.29 TyperOption give for the number type and bounds? The issue lists bare_type, display_type, param_type_name but no type. If 0.29 builds the click type lazily (a method, such as get_type() or a conversion done at parse time), the adapter calls that. If it exposes no range at all, option A fails: then state it in the docstring as a stated limit and ask the maintainer whether the allowed range stays below 0.29 (that is a decision; stop and ask).
    • First step, no decision needed: print vars(param) of one bounded and one unbounded numeric option on 0.27.3 and on 0.29.1 and paste both in a comment here.
    • Does _refuses (calls convert(value, None, None)) still work if the type object differs in 0.29?

    6. Pointers

    • tests/test_cli_import_typer_keywords.py (reads source with ast, no second Typer needed).
    • tests/test_cli_numeric_options_declare_a_range.py (checker and plants).
    • .github/workflows/unlocked.yml.

    7. Checked versus assumed

    Checked by reading: the six .type sites, the five click_type= plants, the diff of #1604 (it touched only the docstring lines of this test, 10 lines) and the diff of open draft PR #1614. Assumed: the issue's 33/5 counts and what 0.29 exposes (not run: no 0.29 environment here). This groom is wrong if 0.29 TyperOption offers no way to recover the number type and range.
    Predicted footprint: 1 existing file, about 40 to 80 changed lines, no new file. No production code.
    Spike? No, but the first step in section 5 is mandatory and must precede any edit.

    Dispatch

    Acceptance:   On Typer 0.27.3 and 0.29.x, tests/test_cli_numeric_options_declare_a_range.py passes with the same count of
                  classified parameters on both (print the counts in the PR). A planted unbounded numeric option is
                  reported on both; the planted tests are red when the checker's read of the type is broken. No
                  file-wide skip on a version; a plant that needs click_type= runs only where the keyword exists.
                  Fails today: that file on 0.29.1 (33 errors).
    Regimes:      Typer below 0.27 allowed by pyproject but not installed in CI (state as unverified); a 0.29 that exposes no
                  range (stated limit, then a decision).
    Shapes:       6 `.type` reads; 5 `click_type=` plants; 1 FuncParamType pin; the test is parametrised over both Typer
                  behaviours through the adapter, with a fake parameter object so the adapter's two branches both run in the
                  locked environment.
    Touches:      existing: tests/test_cli_numeric_options_declare_a_range.py   new: none
    Sequence:     independent of #1614 (it edits docstring lines 3-10 and lines 263-440; this edits 182, 213-214, 531, 625-660,
                  704-706). Whichever lands second rebases without a shared hunk.
    Model:        opus (an unknown API to find)
    Effort:       S to M
    heavy:        no
    Cold read:    no
    Out of scope: moving the lock to 0.29 (unlocked.yml already runs weekly); production code (nothing under pyrite/ or
                  extensions/ reads param.type, per the issue's grep).
    Decision:     only if 0.29 exposes no range: keep the allowed Typer range below 0.29 or state the limit? Recommendation:
                  state the limit and keep the range open.
    

    How a contributor proves it without two Typers in CI: unit-test the adapter with a small fake parameter that has .type and one that has only the 0.29 attributes, so both branches run on the locked Typer; run the file once by hand in a 0.29.1 virtualenv and paste the counts; the Monday unlocked.yml run is the standing check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliCommand-line interfacequalityRefactoring, test refactoring, code health

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions