For unions, handle string types last#209
Open
brentyi wants to merge 493 commits into
Open
Conversation
It does not appear to be used for anything other than tests
* Support os.PathLike * Fix missing import, add os.PathLike helptext test * Un-rename file to avoid merge conflict
…__ (#38) * Add support for PathLike classes & objects with __new__ but no __init__ * Update _instantiators.py * Formatting --------- Co-authored-by: Brent Yi <yibrenth@gmail.com>
* Start subcommand matching refactor * Improve test coverage * Format * Patch for 3.7
Previously, if a `str` type argument's default value contains `%`, the `--help` action fails. Reproducible example: ```bash $ cat >percent-char.py <<EOF import tyro from dataclasses import dataclass @DataClass class A: name: str = "%" def main(args: A): print(args.name) if __name__ == "__main__": tyro.cli(main) EOF $ python percent-char.py --help [...truncated...] File "/.../lib/python3.9/argparse.py", line 630, in _expand_help return self._get_help_string(action) % params ValueError: unsupported format character ')' (0x29) at index 29 ``` This commit fixes this and updates the test for default help text to cover this case. Signed-off-by: Gaoyang Zhang <gy@blurgy.xyz>
* Improvements for numeric tower edge cases * Fix test for Python <3.10
* Docs pass, primitive rule priority * Fix default primitive rules * tests * sync docs * union fix
* Docs / examples rework * nits * Refinements * ruff * ignore mypy errors for docs update script
* Helptext, docs fixes * refine
* Support Python 3.13 * Update pyproject.toml * Test annotated struct narrowing * ruff * mypy * Add narrow_subtype test * ruff
* Constructors + examples refinements * formatting/regenerate docs * Move test * ruff * Python 3.7 * ruff
* Apply `use_underscores` to subcommand names for `tyro.extras.SubcommandApp` * pydantic NewType fix
…oved error messages (#204) * Improve mismatched type for StrEnum * Overhaul subcommand matching * Additional subcommand matching tests * Min 3.11 for StrEnum tests * fix test ignore * Test nits * typeguard compatibility * Add minimum typeguard version * fix typeguard errors * typeguard refactor, more subcommand matching tests * Add 3.13 to CI (fixes #206) * Add pydantic version exclude, waiting for patch Related: pydantic/pydantic#10912, pydantic/pydantic#10909 * Improve type warnings + errors * Generic subcommand example, docs updates * Remove unused * `build` => `pytest`, closes #206 * mypy
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
==========================================
+ Coverage 99.16% 99.78% +0.62%
==========================================
Files 19 28 +9
Lines 1552 2302 +750
==========================================
+ Hits 1539 2297 +758
+ Misses 13 5 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4751f34 to
289f0a9
Compare
81951eb to
3714e32
Compare
469af36 to
48b37da
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Examples:
arg: Optional[str]andarg: str | None,--arg Nonewill create aNoneobject instead of a string.arg: str | bool,--arg Truewill create a boolean instead of a string.arg: str | int, integers will be created when possible instead of strings.Questions raised:
arg: tuple[str, ...] | int?Optional[list[str]]?