Skip to content

Commit

Permalink
Fix subcommand Callable type annotations
Browse files Browse the repository at this point in the history
- Update _SubcommandConfig constructor_factory type annotation from Callable to Callable[..., Any]
- Update subcommand function parameter type annotations to use Callable[..., Any]
- Fixes stricter pyright type checking errors when using subcommand function

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
  • Loading branch information
brentyi committed Feb 26, 2025
1 parent 5d7aef1 commit a9a3511
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/tyro/conf/_confstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class _SubcommandConfig:
default: Any
description: str | None
prefix_name: bool
constructor_factory: Callable[[], type | Callable] | None
constructor_factory: Callable[[], type | Callable[..., Any]] | None

def __hash__(self) -> int:
return object.__hash__(self)
Expand All @@ -28,7 +28,7 @@ def subcommand(
description: str | None = None,
prefix_name: bool = True,
constructor: None = None,
constructor_factory: Callable[[], type | Callable] | None = None,
constructor_factory: Callable[[], type | Callable[..., Any]] | None = None,
) -> Any: ...


Expand All @@ -39,7 +39,7 @@ def subcommand(
default: Any = MISSING_NONPROP,
description: str | None = None,
prefix_name: bool = True,
constructor: type | Callable | None = None,
constructor: type | Callable[..., Any] | None = None,
constructor_factory: None = None,
) -> Any: ...

Expand All @@ -50,8 +50,8 @@ def subcommand(
default: Any = MISSING_NONPROP,
description: str | None = None,
prefix_name: bool = True,
constructor: type | Callable | None = None,
constructor_factory: Callable[[], type | Callable] | None = None,
constructor: type | Callable[..., Any] | None = None,
constructor_factory: Callable[[], type | Callable[..., Any]] | None = None,
) -> Any:
"""Returns a metadata object for configuring subcommands with
:py:data:`typing.Annotated`. Useful for aesthetics.
Expand Down

0 comments on commit a9a3511

Please # to comment.