Repository navigation
Breaking changes
- No more global state (#157):
Configis a per-call object,select(..., config=Config(...)), carryingconsoleandkeys(DefaultKeys→KeyBindings). Module-levelconsoleis removed. Using a removed global raisesRemovedInV4Error(orAttributeErrorwhen assigning on theConfig/KeyBindingsclass) with a message explaining the replacement. - Keyword-only arguments: only the first argument of
select,select_multiple,prompt,confirmandSpinneris positional (Spinner(DOTS, text="...")). - Ctrl+C raises
KeyboardInterruptby default (Config.raise_on_interrupt=True). It used to returnNone, so a script carried on as if the user had chosen "nothing". Esc still returnsNone. strictdefaults toTrueonselect/select_multiple(#157): emptyoptionsraisesValueErrorunlessstrict=Falseis passed.paginationflag removed.page_sizealone now controls paging:Nonefits the terminal and paginates only when needed, an integer always paginates with that many options per page. Before,page_sizewas silently ignored unlesspagination=Truewas passed too, andpagination=Falsecould not actually turn paging off.- Select-all is
ctrl+ainstead ofa, soacan be typed into a filter. Select-all keeps existing ticks (filling up tomaximal_countin list order) and acts on visible options when filtering. - Default console no longer highlights (
Console(stderr=True, highlight=False)), restoring the 3.8.2 look. - Dependencies:
emojiis dropped andrich>=14.3.0is required. Cursor/tick widths now come fromrich.cells.cell_len, which matchesemojion every cursor/tick tried and is more accurate for CJK and combining characters, but only measures variation-selector/ZWJ emoji correctly from Rich 14.3 (which still supports Python 3.8). - Python:
>=3.8is still declared, but only 3.10+ is tested in CI (noted in the README). The built wheel imports on 3.8, 3.9, 3.10 and 3.14.
New features
- Title and instructions (#135, discussion #106):
title=onselect/select_multiple,instructions=on all elements (Nonehides it). - Sectioned options (#74): pass a dict of section name to options. Indices are
(section, index)tuples, enforced at runtime and by type checkers via@overload. - Filtering (#201):
filterable=Truenarrows options by typed text (case-insensitive, markup ignored), and shows a(matches/total)count next to the query (#157). - Input validation, fail loud (#157):
- A blank option (after preprocessing and stripping markup) or blank section name always raises
ValueErrornaming the entry, e.g.option at ('Veg', 1) is blank,section name '' is blank. Not gated bystrict. - A bare string as
optionsraisesTypeErrorinstead of silently offering its letters. confirmraises on a blankyes_text/no_text(it used to crash withIndexError) and when both labels start with the same letter while the(Y/N)hint is shown.- Without an interactive terminal (piped stdin, most CI), every element raises
RuntimeError('Interactive terminal required')instead of an opaquetermios.error.
- A blank option (after preprocessing and stripping markup) or blank section name always raises
Spinneris a context manager (with Spinner(...):also stops it if the body raises) and acceptsconsole=so it can share a console with the other elements.- Typing:
py.typedis now shipped (the wheel had none, so the overloads were invisible to downstream type checkers).prompt(..., target_type=int)is typedOptional[int]and its validator is checked against that type.optionsaccepts anySequence/Mapping; tuples and ranges already worked at runtime.__all__and__version__are declared. - Exceptions:
ValidationErrorandConversionErrorare nowValueErrorsubclasses. A failed validator can no longer be mistaken for a failed conversion, and a validator that raisesValueErroritself is no longer swallowed as one.
Fixes
- Automatic page size subtracted a hard-coded 6 lines in
selectbut only 1 inselect_multiple, soselect_multiplerendered taller than the terminal and Rich'sLivecropped its page indicator and instructions (confirmed in a real pty). It is now derived from what is actually rendered (title/filter line, page indicator, instructions, the error line when min/max counts can produce one), identically for both, and section headers are bounded by what a page can hold. A property test asserts no render is taller than the terminal across heights, section counts, titles, filtering and error states. prompt()docstring pointed at a nonexistentrich.internalsmodule.
Docs
docs/content/examples.md: rewritten Configuration section, new sections for title/instructions/sections, filtering, pagination, input validation and spinners, and a 3.x → 4.x migration table. The README spinner example uses the context manager.
Tooling & CI
- Poetry → uv.
[tool.poetry]→ PEP 621[project],poetry.lock→uv.lock, build backendpoetry-core→uv_build. Releases now build and publish withuv build/uv publishinstead of Poetry +pypa/gh-action-pypi-publish. requirements-dev.txt/docs/requirements.txt(hand-pinned, unlocked, installed via two separate untrackedpip installs) folded into[dependency-groups]dev/docs, resolved and hash-locked together inuv.lock. Declared as[tool.uv] conflictssince they were never actually installed together (dev'swatchdog==6.0.0vs.novella'swatchdog<3.0.0).- Dropped dead dependencies never wired into any task or CI step:
expycted,mock(tests use stdlibunittest.mock),radon,xenon,toml-sort,perflint, a duplicatepydoc-markdownpin, andtypes-emoji. - flake8 + 10 plugins + black + isort → ruff.
ruff check/ruff formatreplacepflake8,black,isort, andflake8-simplify/-pie/-bandit/-cognitive-complexity/-expression-complexity/-quotes/-print/-eradicate. Fixed the 8 real findings ruff's rules turned up that flake8's narrowerselectlist and dead plugins never caught. - mypy kept (ruff doesn't type-check).
- CodeQL and dependency-review workflows removed. SonarCloud kept. The
relock-with-autocommit job replaced with a plainuv lock --check. - Two third-party GitHub Actions pinned to commit SHAs (
astral-sh/setup-uv,JamesIves/github-pages-deploy-action), flagged by Sonar as a high-severity supply-chain risk (tag refs are mutable). docsgroup needsuv pip install --group docsrather thanuv sync: novella'spkg_resources-based plugin loader can't resolveuv's dist-info metadata for dotted distribution names (e.g.databind.json). Also needssetuptools<81(pkg_resourceswas removed in 81+).