Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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', '3.13']
steps:
- uses: actions/checkout@v1
with:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions radicli/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,28 @@ 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_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()

Expand Down
3 changes: 2 additions & 1 deletion radicli/util.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -334,7 +335,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
Expand Down
9 changes: 5 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down