-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from DanCardin/dc/one-or-more
fix: Required positional arguments in native parser.
- Loading branch information
Showing
10 changed files
with
144 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
|
||
from typing_extensions import Annotated | ||
|
||
import cappa | ||
from tests.utils import parse | ||
|
||
|
||
def test_unbounded_list_option(): | ||
@dataclass | ||
class Args: | ||
unbounded: Annotated[list[list[int]], cappa.Arg(short=True)] | ||
|
||
result = parse(Args, "-u", "0") | ||
assert result == Args([[0]]) | ||
|
||
result = parse(Args, "-u", "0", "1", "2", "3", "4", "5") | ||
assert result == Args([[0, 1, 2, 3, 4, 5]]) | ||
|
||
|
||
def test_unbounded_set_option(): | ||
@dataclass | ||
class Args: | ||
unbounded: Annotated[set[tuple[int, int]], cappa.Arg(short=True)] | ||
|
||
result = parse(Args, "-u", "0", "1") | ||
assert result == Args({(0, 1)}) | ||
|
||
|
||
def test_unbounded_tuple_option(): | ||
@dataclass | ||
class Args: | ||
unbounded: Annotated[tuple[list[int], ...], cappa.Arg(short=True)] | ||
|
||
result = parse(Args, "-u", "0") | ||
assert result == Args(([0],)) | ||
|
||
result = parse(Args, "-u", "0", "1", "2", "3", "4", "5") | ||
assert result == Args(([0, 1, 2, 3, 4, 5],)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.