Skip to content

Commit

Permalink
Add test for typing.Text
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Nov 10, 2024
1 parent 1065135 commit f150c73
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_dcargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
Dict,
List,
Optional,
Text,
Tuple,
TypeVar,
Union,
)

import pytest
import torch
from typing_extensions import Annotated, Final, Literal, TypeAlias

import tyro
from typing_extensions import Annotated, Final, Literal, TypeAlias


def test_no_args() -> None:
Expand Down Expand Up @@ -573,6 +573,15 @@ def main(x: AnyStr) -> AnyStr:
assert tyro.cli(main, args=["--x", "hello„"]) == "hello„"


def test_text() -> None:
# `Text` is an alias for `str` in Python 3.
def main(x: Text) -> Text:
return x

assert tyro.cli(main, args=["--x", "hello"]) == "hello"
assert tyro.cli(main, args=["--x", "hello„"]) == "hello„"


def test_fixed() -> None:
def main(x: Callable[[int], int] = lambda x: x * 2) -> Callable[[int], int]:
return x
Expand Down

0 comments on commit f150c73

Please sign in to comment.