From c51f348c8f8331b15aee127f080f0ddd31bd4a69 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Thu, 12 Feb 2026 10:40:28 +0100 Subject: [PATCH 1/5] Support optional syntax with | --- radicli/tests/test_cli.py | 13 +++++++++++++ radicli/util.py | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/radicli/tests/test_cli.py b/radicli/tests/test_cli.py index 831a078..5a83894 100644 --- a/radicli/tests/test_cli.py +++ b/radicli/tests/test_cli.py @@ -1003,6 +1003,19 @@ def test(a: str, b: str = "1", *, c: int = 1, d: bool = False, e: str = "yo"): assert parsed == {"a": "hello", "c": 1, "d": True} +def test_cli_optional_syntax(): + cli = Radicli() + + @cli.command("test", a=Arg("--a"), b=Arg("--b")) + def test(a: str | None, b: Optional[str]): + ... + + parsed = cli.parse(["--a", "hello"], cli.commands["test"]) + assert parsed == {"a": "hello", "b": None} + parsed = cli.parse(["--b", "hello"], cli.commands["test"]) + assert parsed == {"a": None, "b": "hello"} + + def test_cli_booleans(): cli = Radicli() diff --git a/radicli/util.py b/radicli/util.py index 500338a..c7d5a90 100644 --- a/radicli/util.py +++ b/radicli/util.py @@ -1,6 +1,7 @@ from typing import Any, Callable, Iterable, Type, Union, Optional, Dict, Tuple from typing import List, Literal, NewType, get_args, get_origin, TypeVar from typing import TypedDict, cast +from types import UnionType from enum import Enum from uuid import UUID from dataclasses import dataclass @@ -328,7 +329,7 @@ def get_arg( return arg if skip_resolve: return arg - if origin is Union: + if origin in (Union, UnionType): # UnionType is | syntax if type(None) in args and default is DEFAULT_PLACEHOLDER: default = None arg_types = [a for a in args if a != type(None)] # noqa: E721 From 4c18636c2deacb173b903d122dcb15855bc3b564 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Thu, 12 Feb 2026 10:40:59 +0100 Subject: [PATCH 2/5] Require Python 3.10+ --- .github/workflows/test.yml | 2 +- README.md | 2 +- setup.cfg | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 39179b4..316c238 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.10'] steps: - uses: actions/checkout@v1 with: diff --git a/README.md b/README.md index 4285d17..e134e1b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ## ⏳ Installation -Note that `radicli` currently requires **Python 3.8+**. +Note that `radicli` currently requires **Python 3.10+**. ```bash pip install radicli diff --git a/setup.cfg b/setup.cfg index f96d49e..60d0778 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [metadata] -version = 0.0.26 +version = 0.1.0 description = Radically lightweight command-line interfaces url = https://github.com/explosion/radicli author = Explosion @@ -17,16 +17,17 @@ classifiers = Operating System :: MacOS :: MacOS X Operating System :: Microsoft :: Windows Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 + Programming Language :: Python :: 3.14 Topic :: Scientific/Engineering [options] zip_safe = true include_package_data = true -python_requires = >=3.8 +python_requires = >=3.10 [sdist] formats = gztar From 1e88118c54371508f4427c635d724c78c03ad6da Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Thu, 12 Feb 2026 10:48:02 +0100 Subject: [PATCH 3/5] Update tests --- radicli/tests/test_cli.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/radicli/tests/test_cli.py b/radicli/tests/test_cli.py index d5273fa..de8d1a9 100644 --- a/radicli/tests/test_cli.py +++ b/radicli/tests/test_cli.py @@ -1013,8 +1013,7 @@ def test_cli_optional_syntax(): cli = Radicli() @cli.command("test", a=Arg("--a"), b=Arg("--b")) - def test(a: str | None, b: Optional[str]): - ... + def test(a: str | None, b: Optional[str]): ... parsed = cli.parse(["--a", "hello"], cli.commands["test"]) assert parsed == {"a": "hello", "b": None} @@ -1022,6 +1021,16 @@ def test(a: str | None, b: Optional[str]): assert parsed == {"a": None, "b": "hello"} +def test_cli_pipe_syntax(): + cli = Radicli() + + @cli.command("test", a=Arg("--a"), b=Arg("--b")) + def test(a: float | int, b: Path | str): ... + + parsed = cli.parse(["--a", "1", "--b", "/path"], cli.commands["test"]) + assert parsed == {"a": 1.0, "b": Path("/path")} + + def test_cli_booleans(): cli = Radicli() From 822e54ad8740ff0326725439a8319e2f007d54fe Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Thu, 12 Feb 2026 10:49:11 +0100 Subject: [PATCH 4/5] Update test matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 316c238..610b39f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.10'] + python-version: ['3.10', '3.13'] steps: - uses: actions/checkout@v1 with: From f136051e3917d1792d6cc5a121f9283038f91138 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Thu, 12 Feb 2026 10:55:24 +0100 Subject: [PATCH 5/5] Fix build --- .github/workflows/test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 610b39f..533fb4f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,11 +21,13 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install - run: pip install -r requirements.txt + run: | + pip install -r requirements.txt + pip install build - name: Run pyright run: python -m pyright ${{ env.PACKAGE }} - name: Build sdist - run: python setup.py sdist + run: python -m build --sdist - name: Remove package directory run: rm -rf ${{ env.PACKAGE }} shell: bash