-
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.
Add support for overriding param and return types
- Loading branch information
Showing
6 changed files
with
85 additions
and
47 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
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,15 @@ | ||
from typing import Any, Callable, Dict, NamedTuple, Optional | ||
|
||
|
||
class Command(NamedTuple): | ||
name: str | ||
function: Callable[..., Any] | ||
parameter_types: Optional[Dict[str, Callable]] | ||
return_type: Optional[Callable[[Any], Any]] | ||
|
||
@staticmethod | ||
def from_func(function: Callable, name: Optional[str] = None) -> "Command": | ||
"""Convience function for what should be the most common case: | ||
Creating a Command from a Python function with no bells or whistles | ||
""" | ||
return Command(name or function.__name__, function, None, None) |