forked from coqui-ai/coqpit
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #5 from idiap/fixes
Fix argument parsing, improve test coverage
- Loading branch information
Showing
8 changed files
with
101 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: Setup uv | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install uv | ||
uses: astral-sh/setup-uv@v3 | ||
with: | ||
version: "0.5.1" | ||
enable-cache: true | ||
cache-dependency-glob: "**/pyproject.toml" |
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
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,44 @@ | ||
from typing import Union | ||
|
||
from coqpit.coqpit import _is_optional_field, _is_union, _is_union_and_not_simple_optional | ||
|
||
# TODO: `type: ignore` can probably be removed when switching to Python 3.10 | ||
# Union syntax (e.g. str | int) | ||
|
||
|
||
def test_is_union() -> None: | ||
cases = ( | ||
(Union[str, int], True), | ||
(Union[str, None], True), | ||
(int, False), | ||
(list[int], False), | ||
(list[Union[str, int]], False), | ||
) | ||
for item, expected in cases: | ||
assert _is_union(item) == expected # type: ignore[arg-type] | ||
|
||
|
||
def test_is_union_and_not_simple_optional() -> None: | ||
cases = ( | ||
(Union[str, int], True), | ||
(Union[str, None], False), | ||
(Union[list[int], None], False), | ||
(int, False), | ||
(list[int], False), | ||
(list[Union[str, int]], False), | ||
) | ||
for item, expected in cases: | ||
assert _is_union_and_not_simple_optional(item) == expected # type: ignore[arg-type] | ||
|
||
|
||
def test_is_optional_field() -> None: | ||
cases = ( | ||
(Union[str, int], False), | ||
(Union[str, None], True), | ||
(Union[list[int], None], True), | ||
(int, False), | ||
(list[int], False), | ||
(list[Union[str, int]], False), | ||
) | ||
for item, expected in cases: | ||
assert _is_optional_field(item) == expected # type: ignore[arg-type] |