Skip to content

Commit

Permalink
Fix missing import, add os.PathLike helptext test
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Feb 14, 2023
1 parent 4abc342 commit 69e4059
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions tests/test_helptext.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dataclasses
import enum
import os
import pathlib
from collections.abc import Callable
from typing import Any, Dict, Generic, List, Optional, Tuple, TypeVar, Union, cast
Expand Down Expand Up @@ -562,3 +563,11 @@ def main2(x: Callable = nn.ReLU):
assert "--x {fixed}" in helptext
assert "(fixed to:" in helptext
assert "torch" in helptext


def test_pathlike() -> None:
def main(x: os.PathLike) -> None:
pass

helptext = get_helptext(main)
assert "--x PATH " in helptext
5 changes: 3 additions & 2 deletions tests/test_tyro.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import copy
import dataclasses
import enum
import os
import pathlib
from typing import (
Any,
Expand Down Expand Up @@ -551,7 +552,7 @@ def main() -> argparse.ArgumentParser:


def test_pathlike():
def main(x: os.PathLike, /) -> os.PathLike:
def main(x: os.PathLike) -> os.PathLike:
return x

assert tyro.cli(main, args=["/dev/null"]) == pathlib.Path("/dev/null")
assert tyro.cli(main, args=["--x", "/dev/null"]) == pathlib.Path("/dev/null")

0 comments on commit 69e4059

Please sign in to comment.