diff --git a/README.rst b/README.rst index 0f37a9e..0beb1eb 100644 --- a/README.rst +++ b/README.rst @@ -233,9 +233,9 @@ enough; in these cases the powerful API of `argparse` is also available: .. code-block:: python - @arg("text", default="hello world", nargs="+", help="The message") - def echo(text: str) -> None: - print text + @arg("words", default="hello world", nargs="+", help="The message") + def echo(words: list[str]) -> str: + return " ".join(words) Please note that decorators will soon be fully replaced with annotations. diff --git a/docs/source/subparsers.rst b/docs/source/subparsers.rst index 54235b9..1960779 100644 --- a/docs/source/subparsers.rst +++ b/docs/source/subparsers.rst @@ -26,7 +26,7 @@ The equivalent code without `Argh` would be:: bar_parser.set_defaults(function=bar) args = parser.parse_args() - print args.function(args) + print(args.function(args)) Now consider this expression:: @@ -54,7 +54,7 @@ to write something like this (generic argparse API):: foo_quux_parser.set_defaults(function=quux) args = parser.parse_args() - print args.function(args) + print(args.function(args)) .. note:: diff --git a/src/argh/dispatching.py b/src/argh/dispatching.py index 784bf2e..ef413f6 100644 --- a/src/argh/dispatching.py +++ b/src/argh/dispatching.py @@ -527,13 +527,13 @@ class EntryPoint: app = EntryPoint("main", {"description": "This is a cool app"}) @app - def ls() -> None: + def ls() -> Iterator[int]: for i in range(10): - print i + yield i @app - def greet() -> None: - print "hello" + def greet() -> str: + return "hello" if __name__ == "__main__": app()