Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-argh for openSUSE:Factory checked in at 2024-01-21 23:08:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-argh (Old) and /work/SRC/openSUSE:Factory/.python-argh.new.16006 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-argh" Sun Jan 21 23:08:42 2024 rev:24 rq:1140108 version:0.31.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-argh/python-argh.changes 2024-01-09 20:50:33.858207314 +0100 +++ /work/SRC/openSUSE:Factory/.python-argh.new.16006/python-argh.changes 2024-01-21 23:09:04.995095406 +0100 @@ -1,0 +2,7 @@ +Sat Jan 20 12:41:49 UTC 2024 - Dirk Müller <dmuel...@suse.com> + +- update to 0.31.1: + * broken support for type alias `List` + * cleaned up the README, rearranged other documentation. + +------------------------------------------------------------------- Old: ---- argh-0.31.0.tar.gz New: ---- argh-0.31.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-argh.spec ++++++ --- /var/tmp/diff_new_pack.VcsuuZ/_old 2024-01-21 23:09:05.511114216 +0100 +++ /var/tmp/diff_new_pack.VcsuuZ/_new 2024-01-21 23:09:05.515114362 +0100 @@ -16,9 +16,9 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} +%{?sle15_python_module_pythons} Name: python-argh -Version: 0.31.0 +Version: 0.31.1 Release: 0 Summary: An argparse wrapper License: LGPL-3.0-or-later ++++++ argh-0.31.0.tar.gz -> argh-0.31.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argh-0.31.0/AUTHORS.rst new/argh-0.31.1/AUTHORS.rst --- old/argh-0.31.0/AUTHORS.rst 2023-12-30 19:22:23.321171300 +0100 +++ new/argh-0.31.1/AUTHORS.rst 1970-01-01 01:00:00.000000000 +0100 @@ -1,91 +0,0 @@ -Contributors -============ - -.. note:: - - This list used to be manually updated at the early stages of Argh - development. As the list of contributions grew, it became increasingly - harder to track them. - - Fortunately, Github offers this awesome tool: - https://github.com/neithere/argh/graphs/contributors - - Please refer to the Github report for recent contributions. - - Also, please don't hesitate to file issues_ and create pull requests - and *become a contributor*! â¤ï¸ - -.. _issues: https://github.com/neithere/argh/issues - -Historical List of Contributors -------------------------------- - -Here is an inevitably incomplete list of contributors, i.e. people who have -suggested features, reported bugs, submitted patches, wrote packaging scripts -and generally made *Argh* better: - -:Andrey Mikhaylenko: Author, Maintainer -:Gora Khargosh: Bug reports -:Mika Eloranta: Patches -:Fabien Devaux: ArchLinux package -:Hannu Valtonen: Debian package -:Georges Dubus: Python3 support fixes -:Roman Ovchinnikov: Debian package -:thethomasw: Python2.6 bug reports -:Tuk Bredsdorff: List of similar projects -:Mike Gilbert: Gentoo package; patch -:Marco Nenciarini: Patch for shell completion and more -:Matt Black: Patch re TTY -:Tony Narlock: Adaptation of README to GitHub -:Oskari Saarenmaa: Compatibility improvements -:Denis Lisov: Support for keyword-only arguments (Python 3) -:Jörg Doppler: Defaults in argument help message, raw docstrings -:Paul Jacobson: Defaults in argument help message, raw docstrings -:Chuck Blake: Support for Cython -:invl: Idea and basic implementation of EntryPoint -:illumin-us-r3v0lution: Questions and examples of setuptools integration -:Joseph McCullough: Patch for dev environ -:Jason Dusek: Patch for EntryPoint -:Felix Yan: Fix missing test dependencies -:David Warde-Farley: Bugfix -:Jakub Wilk: Fix spelling in docs -:Brian Lee: Support for signatures of funcs behind @wraps deco - -...you? :-) - Patches, ideas and any feedback is highly appreciated. - -Acknowledgements ----------------- - -Early versions were somewhat inspired by Alexander Solovyov's opster_. - -.. _opster: https://pypi.org/pypi/opster - -Thanks to the authors of argparse_ for the excellent library for which Argh -is merely a wrapper. - -.. _argparse: https://docs.python.org/3/library/argparse.html - -Thanks to Andrey Kislyuk for writing argcomplete_ and thus allowing Argh -to remain compact. - -.. _argcomplete: https://pypi.python.org/pypi/argcomplete - -Thanks to the authors of py.test_, tox_, virtualenv_, mock_ and related -projects (or ideas) for automating the routine and letting the developer focus -on the task and enjoy TDD. - -.. _py.test: https://pypi.org/pypi/pytest -.. _tox: http://pypis.org/pypi/tox -.. _virtualenv: https://pypi.org/pypi/virtualenv -.. _mock: https://pypi.org/pypi/mock - -Thanks to Bitbucket_ team for the not-too-commercial approach to the excellent -tools they provide. The early years of Argh development were spent on that -platform. - -Thanks to Github_ team for the place where Argh has been developed for over a -decade. - -.. _bitbucket: https://bitbucket.org -.. _github: https://github.com diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argh-0.31.0/CHANGES.rst new/argh-0.31.1/CHANGES.rst --- old/argh-0.31.0/CHANGES.rst 2023-12-30 19:22:23.321171300 +0100 +++ new/argh-0.31.1/CHANGES.rst 1970-01-01 01:00:00.000000000 +0100 @@ -1,491 +0,0 @@ -Changelog -========= - -Version 0.31.0 (2023-12-30) ---------------------------- - -Breaking changes: - -- The typing hints introspection feature is automatically enabled for any - command (function) which does **not** have any arguments specified via `@arg` - decorator. - - This means that, for example, the following function used to fail and now - it will pass:: - - def main(count: int): - assert isinstance(count, int) - - This may lead to unexpected behaviour in some rare cases. - -- A small change in the legacy argument mapping policy `BY_NAME_IF_HAS_DEFAULT` - concerning the order of variadic positional vs. keyword-only arguments. - - The following function now results in ``main alpha [args ...] beta`` instead of - ``main alpha beta [args ...]``:: - - def main(alpha, *args, beta): ... - - This does **not** concern the default name mapping policy. Even for the - legacy one it's an edge case which is extremely unlikely to appear in any - real-life application. - -- Removed the previously deprecated decorator `@expects_obj`. - -Enhancements: - -- Added experimental support for basic typing hints (issue #203) - - The following hints are currently supported: - - - ``str``, ``int``, ``float``, ``bool`` (goes to ``type``); - - ``list`` (affects ``nargs``), ``list[T]`` (first subtype goes into ``type``); - - ``Literal[T1, T2, ...]`` (interpreted as ``choices``); - - ``Optional[T]`` AKA ``T | None`` (currently interpreted as - ``required=False`` for optional and ``nargs="?"`` for positional - arguments; likely to change in the future as use cases accumulate). - - The exact interpretation of the type hints is subject to change in the - upcoming versions of Argh. - -- Added `always_flush` argument to `dispatch()` (issue #145) - -- High-level functions `argh.dispatch_command()` and `argh.dispatch_commands()` - now accept a new parameter `old_name_mapping_policy`. The behaviour hasn't - changed because the parameter is `True` by default. It will change to - `False` in Argh v.0.33 or v.1.0. - -Deprecated: - -- the `namespace` argument in `argh.dispatch()` and `argh.parse_and_resolve()`. - Rationale: continued API cleanup. It's already possible to mutate the - namespace object between parsing and calling the endpoint; it's unlikely that - anyone would need to specify a custom namespace class or pre-populate it - before parsing. Please file an issue if you have a valid use case. - -Other changes: - -- Refactoring. - -Version 0.30.5 (2023-12-25) ---------------------------- - -Bugs fixed: - -- A combination of `nargs` with a list as default value would lead to the - values coming from CLI being wrapped in another list (issue #212). - -Enhancements: - -- Argspec guessing: if `nargs` is not specified but the default value - is a list, ``nargs="*"`` is assumed and passed to argparse. - -Version 0.30.4 (2023-11-04) ---------------------------- - -There were complaints about the lack of a deprecation cycle for the legacy name -mapping policy. This version addresses the issue: - -- The handling introduced in v.0.30.2 (raising an exception for clarity) - is retained for cases when no name mapping policy is specified but function - signature contains defaults in non-kwonly args **and kwonly args are also - defined**:: - - def main(alpha, beta=1, *, gamma=2): # error â explicit policy required - - In a similar case but when **kwonly args are not defined** Argh now assumes - the legacy name mapping policy (`BY_NAME_IF_HAS_DEFAULT`) and merely issues - a deprecation warning with the same message as the exception mentioned above:: - - def main(alpha, beta=2): # `[-b BETA] alpha` + DeprecationWarning - - This ensures that most of the old scripts still work the same way despite the - new policy being used by default and enforced in cases when it's impossible - to resolve the mapping conflict. - - Please note that this "soft" handling is to be removed in version v0.33 - (or v1.0 if the former is not deemed necessary). The new name mapping policy - will be used by default without warnings, like in v0.30. - -Version 0.30.3 (2023-10-30) ---------------------------- - -Bugs fixed: - -- Regression: a positional argument with an underscore used in `@arg` decorator - would cause Argh fail on the assembling stage. (#208) - -Version 0.30.2 (2023-10-24) ---------------------------- - -Bugs fixed: - -- As reported in #204 and #206, the new default name mapping policy in fact - silently changed the CLI API of some scripts: arguments which were previously - translated as CLI options became optional positionals. Although the - instructions were supplied in the release notes, the upgrade may not - necessarily be intentional, so a waste of users' time is quite likely. - - To alleviate this, the default value for `name_mapping_policy` in standard - functions has been changed to `None`; if it's not specified, Argh falls back - to the new default policy, but raises `ArgumentNameMappingError` with - detailed instructions if it sees a non-kwonly argument with a default value. - - Please specify the policy explicitly in order to avoid this error if you need - to infer optional positionals (``nargs="?"``) from function signature. - -Version 0.30.1 (2023-10-23) ---------------------------- - -Bugs fixed: - -- Regression: certain special values in argument default value would cause an - exception (#204) - -Enhancements: - -- Improved the tutorial. -- Added a more informative error message when the reason is likely to be - related to the migration from Argh v0.29 to a version with a new argument - name mapping policy. - -Other changes: - -- Added `py.typed` marker file for :pep:`561`. - -Version 0.30.0 (2023-10-21) ---------------------------- - -Backwards incompatible changes: - -- A new policy for mapping function arguments to CLI arguments is used by - default (see :class:`argh.assembling.NameMappingPolicy`). - - The following function does **not** map to ``func foo [--bar]`` anymore:: - - def func(foo, bar=None): - ... - - Since this release it maps to ``func foo [bar]`` instead. - Please update the function this way to keep `bar` an "option":: - - def func(foo, *, bar=None): - ... - - If you cannot modify the function signature to use kwonly args for options, - please consider explicitly specifying the legacy name mapping policy:: - - set_default_command( - func, name_mapping_policy=NameMappingPolicy.BY_NAME_IF_HAS_DEFAULT - ) - -- The name mapping policy `BY_NAME_IF_HAS_DEFAULT` slightly deviates from the - old behaviour. Kwonly arguments without default values used to be marked as - required options (``--foo FOO``), now they are treated as positionals - (``foo``). Please consider the new default policy (`BY_NAME_IF_KWONLY`) for - a better treatment of kwonly. - -- Removed previously deprecated features (#184 â #188): - - - argument help string in annotations â reserved for type hints; - - `argh.SUPPORTS_ALIASES`; - - `argh.safe_input()`; - - previously renamed arguments for `add_commands()`: `namespace`, - `namespace_kwargs`, `title`, `description`, `help`; - - `pre_call` argument in `dispatch()`. The basic usage remains simple but - more granular functions are now available for more control. - - Instead of this:: - - argh.dispatch(..., pre_call=pre_call_hook) - - please use this:: - - func, ns = argh.parse_and_resolve(...) - pre_call_hook(ns) - argh.run_endpoint_function(func, ns, ...) - -Deprecated: - -- The `@expects_obj` decorator. Rationale: it used to support the old, - "un-pythonic" style of usage, which essentially lies outside the scope of - Argh. If you are not using the mapping of function arguments onto CLI, then - you aren't reducing the amount of code compared to vanilla Argparse. - -- The `add_help_command` argument in `dispatch()`. - Rationale: it doesn't add much to user experience; it's not much harder to - type ``--help`` than it is to type ``help``; moreover, the option can be - added anywhere, unlike its positional counterpart. - -Enhancements: - -- Added support for Python 3.12. -- Added type annotations to existing Argh code (#185 â #189). -- The `dispatch()` function has been refactored, so in case you need finer - control over the process, two new, more granular functions can be used: - - - `endpoint_function, namespace = argh.parse_and_resolve(...)` - - `argh.run_endpoint_function(endpoint_function, namespace, ...)` - - Please note that the names may change in the upcoming versions. - -- Configurable name mapping policy has been introduced for function argument - to CLI argument translation (#191 â #199): - - - `BY_NAME_IF_KWONLY` (default and recommended). - - `BY_NAME_IF_HAS_DEFAULT` (close to pre-v.0.30 behaviour); - - Please check API docs on :class:`argh.assembling.NameMappingPolicy` for - details. - -Version 0.29.4 (2023-09-23) ---------------------------- - -Bugs fixed: - -- Test coverage reported as <100% when argcomplete is installed (#187) - -Versions 0.29.1 through 0.29.3 ------------------------------- - -Technical releases for packaging purposes. No changes in functionality. - -Version 0.29.0 (2023-09-03) ---------------------------- - -Backwards incompatible changes: - -- Wrapped exceptions now cause ``dispatching.dispatch()`` to raise - ``SystemExit(1)`` instead of returning without error. For most users, this - means failed commands will now exit with a failure status instead of a - success. (#161) - -Deprecated: - -- Renamed arguments in `add_commands()` (#165): - - - `namespace` â `group_name` - - `namespace_kwargs` â `group_kwargs` - - The old names are deprecated and will be removed in v.0.30. - -Enhancements: - -- Can control exit status (see Backwards Incompatible Changes above) when - raising ``CommandError`` using the ``code`` keyword arg. - -Bugs fixed: - -- Positional arguments should not lead to removal of short form of keyword - arguments. (#115) - -Other changes: - -- Avoid depending on iocapture by using pytest's built-in feature (#177) - -Version 0.28.1 (2023-02-16) ---------------------------- - -- Fixed bugs in tests (#171, #172) - -Version 0.28.0 (2023-02-15) ---------------------------- - -A major cleanup. - -Backward incompatible changes: - -- Dropped support for Python 2.7 and 3.7. - -Deprecated features, to be removed in v.0.30: - -- `argh.assembling.SUPPORTS_ALIASES`. - - - Always `True` for recent versions of Python. - -- `argh.io.safe_input()` AKA `argh.interaction.safe_input()`. - - - Not relevant anymore. Please use the built-in `input()` instead. - -- argument `pre_call` in `dispatch()`. - - Even though this hack seems to have been used in some projects, it was never - part of the official API and never recommended. - - Describing your use case in the `discussion about shared arguments`_ can - help improve the library to accomodate it in a proper way. - - .. _discussion about shared arguments: https://github.com/neithere/argh/issues/63 - -- Argument help as annotations. - - - Annotations will only be used for types after v.0.30. - - Please replace any instance of:: - - def func(foo: "Foobar"): - - with the following:: - - @arg('-f', '--foo', help="Foobar") - def func(foo): - - It will be decided later how to keep this functionality "DRY" (don't repeat - yourself) without conflicts with modern conventions and tools. - -- Added deprecation warnings for some arguments deprecated back in v.0.26. - -Version 0.27.2 (2023-02-09) ---------------------------- - -Minor packaging fix: - -* chore: include file required by tox.ini in the sdist (#155) - -Version 0.27.1 (2023-02-09) ---------------------------- - -Minor building and packaging fixes: - -* docs: add Read the Docs config (#160) -* chore: include tox.ini in the sdist (#155) - -Version 0.27.0 (2023-02-09) ---------------------------- - -This is the last version to support Python 2.7. - -Backward incompatible changes: - -- Dropped support for Python 2.6. - -Enhancements: - -- Added support for Python 3.7 through 3.11. -- Support introspection of function signature behind the `@wraps` decorator - (issue #111). - -Fixed bugs: - -- When command function signature contained ``**kwargs`` *and* positionals - without defaults and with underscores in their names, a weird behaviour could - be observed (issue #104). -- Fixed introspection through decorators (issue #111). -- Switched to Python's built-in `unittest.mock` (PR #154). -- Fixed bug with `skip_unknown_args=True` (PR #134). -- Fixed tests for Python 3.9.7+ (issue #148). - -Other changes: - -- Included the license files in manifest (PR #112). -- Extended the list of similar projects (PR #87). -- Fixed typos and links in documentation (PR #110, #116, #156). -- Switched CI to Github Actions (PR #153). - -Version 0.26.2 (2016-05-11) ---------------------------- - -- Removed official support for Python 3.4, added for 3.5. -- Various tox-related improvements for development. -- Improved documentation. - -Version 0.26.1 (2014-10-30) ---------------------------- - -Fixed bugs: - -- The undocumented (and untested) argument `dispatch(..., pre_call=x)` - was broken; fixing because at least one important app depends on it - (issue #63). - -Version 0.26 (2014-10-27) -------------------------- - -This release is intended to be the last one before 1.0. Therefore a major -cleanup was done. This **breaks backward compatibility**. If your code is -really outdated, please read this list carefully and grep your code. - -- Removed decorator `@alias` (deprecated since v.0.19). - -- Removed decorator `@plain_signature` (deprecated since v.0.20). - -- Dropped support for old-style functions that implicitly expected namespace - objects (deprecated since v.0.21). The `@expects_obj` decorator is now - mandatory for such functions. - -- Removed decorator `@command` (deprecated since v.0.21). - -- The `@wrap_errors` decorator now strictly requires that the error classes - are given as a list (old behaviour was deprecated since v.0.22). - -- The `allow_warnings` argument is removed from - `argh.completion.autocomplete()`. Debug-level logging is used instead. - (The warnings were deprecated since v.0.25). - -Deprecated: - -- Deprecated arguments `title`, `help` and `description` in `add_commands()` - helper function. See documentation and issue #60. - -Other changes: - -- Improved representation of default values in the help. - -- Dispatcher can be configured to skip unknown arguments (issue #57). - -- Added `add_subcommands()` helper function (a convenience wrapper - for `add_commands()`). - -- `EntryPoint` now stores kwargs for the parser. - -- Added support for default command *with* nested commands (issue #78). - - This only works with Python 3.4+ due to incorrect behaviour or earlier - versions of Argparse (including the stand-alone one as of 1.2.1). - - Due to argparse peculiarities the function assignment technique relies - on a special `ArghNamespace` object. It is used by default in `ArghParser` - and the shortcuts, but if you call the vanilla `ArgumentParser.parse_args()` - method, you now *have* to supply the proper namespace object. - -Fixed bugs: - -- Help formatter was broken for arguments with empty strings as default values - (issue #76). - -Version 0.25 (2014-07-05) -------------------------- - -- Added EntryPoint class as another way to assemble functions (issue #59). - -- Added support for Python 3.4; dropped support for Python 3.3 - (this doesn't mean that Argh is necessarily broken under 3.3, - it's just that I'm not testing against it anymore). - -- Shell completion warnings are now deprecated in favour of `logging`. - -- The command help now displays default values of all arguments (issue #64). - -- Function docstrings are now displayed verbatim in the help (issue #64). - -- Argh's dispatching now should work properly in Cython. - -Versions 0.2 through 0.24 -------------------------- - -A few years of development without a changelog ð« - -Fortunately, a curious reader can always refer to commit messages and -changesets. - -Version 0.1 (2010-11-12) ------------------------- - -The first version! A single file with 182 lines of code including -documentation :) It featured subparsers and had the `@arg` decorator which was -basically a deferred `ArgumentParser.add_argument()` call. - -Functions and classes: - -* class `ArghParser` -* functions `add_commands()` and `dispatch()` -* decorators `@arg` and `@plain_signature` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argh-0.31.0/PKG-INFO new/argh-0.31.1/PKG-INFO --- old/argh-0.31.0/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/argh-0.31.1/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +1,7 @@ Metadata-Version: 2.1 Name: argh -Version: 0.31.0 -Summary: An unobtrusive argparse wrapper with natural syntax +Version: 0.31.1 +Summary: Plain Python functions as CLI commands without boilerplate Keywords: cli,command line,argparse,optparse,argument,option Author-email: Andy Mikhaylenko <neith...@gmail.com> Maintainer-email: Andy Mikhaylenko <neith...@gmail.com> @@ -42,8 +42,8 @@ Provides-Extra: linters Provides-Extra: test -Argh: The Natural CLI -===================== +Argh: The Effortless CLI +======================== .. image:: https://github.com/neithere/argh/actions/workflows/lint-and-test.yml/badge.svg :target: https://github.com/neithere/argh/actions/workflows/lint-and-test.yml @@ -69,21 +69,71 @@ .. image:: https://readthedocs.org/projects/argh/badge/?version=latest :target: http://argh.readthedocs.org/en/latest/ +**The power of Argparse with plain Python functions!** + Building a command-line interface? Found yourself uttering "argh!" while struggling with the API of `argparse`? Don't like the complexity but need the power? -.. epigraph:: +`Argh` builds on the power of `argparse` (which comes with Python) and makes it +really easy to use. It eliminates the complex API and lets you "dispatch" +ordinary Python functions as CLI commands. + +Installation +------------ - Everything should be made as simple as possible, but no simpler. +:: - -- Albert Einstein (probably) + $ pip install argh -`Argh` is a smart wrapper for `argparse`. `Argparse` is a very powerful tool; -`Argh` just makes it easy to use. +Example +------- -In a nutshell -------------- +.. code-block:: python + + import argh + + def verify_paths(paths: list[str], *, verbose: bool = False): + """ + Verify that all given paths exist. + """ + for path in paths: + if verbose: + print(f"Checking {path}...") + assert os.path.exists(path) + + argh.dispatch_command(verify_paths) + +Now you can run the script like this: + +.. code-block:: bash + + $ python app.py foo.txt bar/quux.txt + + $ python app.py foo.txt bar/quux.txt --verbose + Checking foo.txt... + Checking bar/quux.txt... + + $ python app.py -h + usage: app.py [-h] [-v] [paths ...] + + Verify that all given paths exist. + + positional arguments: + paths - + + options: + -h, --help show this help message and exit + -v, --verbose False + +Please check the documentation for examples of multiple commands, modularity, +help generation, advanced type annotations inspection, decorators and more: + +* `Quick Start <https://argh.readthedocs.io/en/latest/quickstart.html>`_ +* `Tutorial <https://argh.readthedocs.io/en/latest/tutorial.html>`_ + +Why Argh? +--------- `Argh`-powered applications are *simple* but *flexible*: @@ -124,198 +174,33 @@ :Compact: No dependencies apart from Python's standard library. -Sounds good? Dive in! :) - -* `Quick Start <https://argh.readthedocs.io/en/latest/quickstart.html>`_ -* `Tutorial <https://argh.readthedocs.io/en/latest/tutorial.html>`_ - -Relation to argparse --------------------- - -`Argh` is fully compatible with `argparse`. You can mix `Argh`-agnostic and -`Argh`-aware code. Just keep in mind that the dispatcher does some extra work -that a custom dispatcher may not do. - -Installation ------------- - -:: - - $ pip install argh - -Examples --------- - -Hello World -........... - -A very simple application with one command: - -.. code-block:: python - - import argh - - def main() -> str: - return "Hello world" - - argh.dispatch_command(main) - -Run it: - -.. code-block:: bash - - $ ./app.py - Hello world - -Type Annotations -................ - -Type annotations are used to infer argument types: - -.. code-block:: python - - def summarise(numbers: list[int]) -> int: - return sum(numbers) - - argh.dispatch_command(summarise) - -Run it (note that ``nargs="+"`` + ``type=int`` were inferred from the -annotation): - -.. code-block:: bash - - $ ./app.py 1 2 3 - 6 - -Multiple Commands -................. - -An app with multiple commands: - -.. code-block:: python - - import argh - - from my_commands import hello, echo - - argh.dispatch_commands([hello, echo]) - -Run it: - -.. code-block:: bash - - $ ./app.py echo Hey - Hey - -Modularity -.......... - -A potentially modular application with more control over the process: - -.. code-block:: python - - import argh - - # declaring: - - def echo(text): - "Returns given word as is." - return text - - def greet(name: str, *, greeting: str = "Hello") -> str: - "Greets the user with given name. The greeting is customizable." - return f"{greeting}, {name}!" - - # assembling: - - parser = argh.ArghParser() - parser.add_commands([echo, greet]) - - # dispatching: - - if __name__ == "__main__": - parser.dispatch() - -.. code-block:: bash - - $ ./app.py greet Andy - Hello, Andy - - $ ./app.py greet Andy -g Arrrgh - Arrrgh, Andy - -Here's the auto-generated help for this application (note how the docstrings -are reused):: - - $ ./app.py --help - - usage: app.py {echo,greet} ... - - positional arguments: - echo Returns given word as is. - greet Greets the user with given name. The greeting is customizable. - -...and for a specific command (an ordinary function signature is converted -to CLI arguments):: - - $ ./app.py --help greet - - usage: app.py greet [-g GREETING] name - - Greets the user with given name. The greeting is customizable. - - positional arguments: - name - - optional arguments: - -g GREETING, --greeting GREETING 'Hello' - -(The help messages have been simplified a bit for brevity.) - -Decorators -.......... - -`Argh` easily maps plain Python functions to CLI. Sometimes this is not -enough; in these cases the powerful API of `argparse` is also available: - -.. code-block:: python - - @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. - Links ----- -* `Project home page`_ (GitHub) -* `Documentation`_ (Read the Docs) -* `Package distribution`_ (PyPI) -* Questions, requests, bug reports, etc.: - - * `Issue tracker`_ (GitHub) - * Direct e-mail (neithere at gmail com) +See also the `project page on GitHub`_, `documentation`_ and `PyPI page`_. -.. _project home page: http://github.com/neithere/argh/ +.. _project page on GitHub: http://github.com/neithere/argh/ .. _documentation: http://argh.readthedocs.org -.. _package distribution: http://pypi.python.org/pypi/argh -.. _issue tracker: http://github.com/neithere/argh/issues/ +.. _PyPI page: http://pypi.python.org/pypi/argh Author ------ Developed by Andrey Mikhaylenko since 2010. -See file `AUTHORS.rst` for a list of contributors to this library. +See `contributors <https://argh.readthedocs.io/en/latest/contributors.html>`_ +for a list of contributors to this library. -Support -------- +Contribute +---------- The fastest way to improve this project is to submit tested and documented patches or detailed bug reports. -You can also `donate via Liberapay`_. This may speed up development or simply +Donate +------ + +You can `donate via Liberapay`_. This may speed up development or simply make the original author happy :) .. _donate via Liberapay: https://liberapay.com/neithere/donate diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argh-0.31.0/README.rst new/argh-0.31.1/README.rst --- old/argh-0.31.0/README.rst 2023-12-30 19:22:23.321171300 +0100 +++ new/argh-0.31.1/README.rst 2024-01-19 17:54:33.584502200 +0100 @@ -1,5 +1,5 @@ -Argh: The Natural CLI -===================== +Argh: The Effortless CLI +======================== .. image:: https://github.com/neithere/argh/actions/workflows/lint-and-test.yml/badge.svg :target: https://github.com/neithere/argh/actions/workflows/lint-and-test.yml @@ -25,21 +25,71 @@ .. image:: https://readthedocs.org/projects/argh/badge/?version=latest :target: http://argh.readthedocs.org/en/latest/ +**The power of Argparse with plain Python functions!** + Building a command-line interface? Found yourself uttering "argh!" while struggling with the API of `argparse`? Don't like the complexity but need the power? -.. epigraph:: +`Argh` builds on the power of `argparse` (which comes with Python) and makes it +really easy to use. It eliminates the complex API and lets you "dispatch" +ordinary Python functions as CLI commands. + +Installation +------------ - Everything should be made as simple as possible, but no simpler. +:: - -- Albert Einstein (probably) + $ pip install argh -`Argh` is a smart wrapper for `argparse`. `Argparse` is a very powerful tool; -`Argh` just makes it easy to use. +Example +------- -In a nutshell -------------- +.. code-block:: python + + import argh + + def verify_paths(paths: list[str], *, verbose: bool = False): + """ + Verify that all given paths exist. + """ + for path in paths: + if verbose: + print(f"Checking {path}...") + assert os.path.exists(path) + + argh.dispatch_command(verify_paths) + +Now you can run the script like this: + +.. code-block:: bash + + $ python app.py foo.txt bar/quux.txt + + $ python app.py foo.txt bar/quux.txt --verbose + Checking foo.txt... + Checking bar/quux.txt... + + $ python app.py -h + usage: app.py [-h] [-v] [paths ...] + + Verify that all given paths exist. + + positional arguments: + paths - + + options: + -h, --help show this help message and exit + -v, --verbose False + +Please check the documentation for examples of multiple commands, modularity, +help generation, advanced type annotations inspection, decorators and more: + +* `Quick Start <https://argh.readthedocs.io/en/latest/quickstart.html>`_ +* `Tutorial <https://argh.readthedocs.io/en/latest/tutorial.html>`_ + +Why Argh? +--------- `Argh`-powered applications are *simple* but *flexible*: @@ -80,198 +130,33 @@ :Compact: No dependencies apart from Python's standard library. -Sounds good? Dive in! :) - -* `Quick Start <https://argh.readthedocs.io/en/latest/quickstart.html>`_ -* `Tutorial <https://argh.readthedocs.io/en/latest/tutorial.html>`_ - -Relation to argparse --------------------- - -`Argh` is fully compatible with `argparse`. You can mix `Argh`-agnostic and -`Argh`-aware code. Just keep in mind that the dispatcher does some extra work -that a custom dispatcher may not do. - -Installation ------------- - -:: - - $ pip install argh - -Examples --------- - -Hello World -........... - -A very simple application with one command: - -.. code-block:: python - - import argh - - def main() -> str: - return "Hello world" - - argh.dispatch_command(main) - -Run it: - -.. code-block:: bash - - $ ./app.py - Hello world - -Type Annotations -................ - -Type annotations are used to infer argument types: - -.. code-block:: python - - def summarise(numbers: list[int]) -> int: - return sum(numbers) - - argh.dispatch_command(summarise) - -Run it (note that ``nargs="+"`` + ``type=int`` were inferred from the -annotation): - -.. code-block:: bash - - $ ./app.py 1 2 3 - 6 - -Multiple Commands -................. - -An app with multiple commands: - -.. code-block:: python - - import argh - - from my_commands import hello, echo - - argh.dispatch_commands([hello, echo]) - -Run it: - -.. code-block:: bash - - $ ./app.py echo Hey - Hey - -Modularity -.......... - -A potentially modular application with more control over the process: - -.. code-block:: python - - import argh - - # declaring: - - def echo(text): - "Returns given word as is." - return text - - def greet(name: str, *, greeting: str = "Hello") -> str: - "Greets the user with given name. The greeting is customizable." - return f"{greeting}, {name}!" - - # assembling: - - parser = argh.ArghParser() - parser.add_commands([echo, greet]) - - # dispatching: - - if __name__ == "__main__": - parser.dispatch() - -.. code-block:: bash - - $ ./app.py greet Andy - Hello, Andy - - $ ./app.py greet Andy -g Arrrgh - Arrrgh, Andy - -Here's the auto-generated help for this application (note how the docstrings -are reused):: - - $ ./app.py --help - - usage: app.py {echo,greet} ... - - positional arguments: - echo Returns given word as is. - greet Greets the user with given name. The greeting is customizable. - -...and for a specific command (an ordinary function signature is converted -to CLI arguments):: - - $ ./app.py --help greet - - usage: app.py greet [-g GREETING] name - - Greets the user with given name. The greeting is customizable. - - positional arguments: - name - - optional arguments: - -g GREETING, --greeting GREETING 'Hello' - -(The help messages have been simplified a bit for brevity.) - -Decorators -.......... - -`Argh` easily maps plain Python functions to CLI. Sometimes this is not -enough; in these cases the powerful API of `argparse` is also available: - -.. code-block:: python - - @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. - Links ----- -* `Project home page`_ (GitHub) -* `Documentation`_ (Read the Docs) -* `Package distribution`_ (PyPI) -* Questions, requests, bug reports, etc.: - - * `Issue tracker`_ (GitHub) - * Direct e-mail (neithere at gmail com) +See also the `project page on GitHub`_, `documentation`_ and `PyPI page`_. -.. _project home page: http://github.com/neithere/argh/ +.. _project page on GitHub: http://github.com/neithere/argh/ .. _documentation: http://argh.readthedocs.org -.. _package distribution: http://pypi.python.org/pypi/argh -.. _issue tracker: http://github.com/neithere/argh/issues/ +.. _PyPI page: http://pypi.python.org/pypi/argh Author ------ Developed by Andrey Mikhaylenko since 2010. -See file `AUTHORS.rst` for a list of contributors to this library. +See `contributors <https://argh.readthedocs.io/en/latest/contributors.html>`_ +for a list of contributors to this library. -Support -------- +Contribute +---------- The fastest way to improve this project is to submit tested and documented patches or detailed bug reports. -You can also `donate via Liberapay`_. This may speed up development or simply +Donate +------ + +You can `donate via Liberapay`_. This may speed up development or simply make the original author happy :) .. _donate via Liberapay: https://liberapay.com/neithere/donate diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argh-0.31.0/pyproject.toml new/argh-0.31.1/pyproject.toml --- old/argh-0.31.0/pyproject.toml 2023-12-30 19:22:23.321171300 +0100 +++ new/argh-0.31.1/pyproject.toml 2024-01-19 17:54:33.588502200 +0100 @@ -4,8 +4,8 @@ [project] name = "argh" -version = "0.31.0" -description = "An unobtrusive argparse wrapper with natural syntax" +version = "0.31.1" +description = "Plain Python functions as CLI commands without boilerplate" readme = "README.rst" requires-python = ">=3.8" license = { file = "COPYING.LESSER" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argh-0.31.0/src/argh/assembling.py new/argh-0.31.1/src/argh/assembling.py --- old/argh-0.31.0/src/argh/assembling.py 2023-12-30 19:22:23.321171300 +0100 +++ new/argh-0.31.1/src/argh/assembling.py 2024-01-19 17:54:33.588502200 +0100 @@ -382,7 +382,7 @@ The policy to use when mapping function arguments onto CLI arguments. See :class:`.NameMappingPolicy`. If not defined explicitly, - :meth:`.NameMappingPolicy.BY_NAME_IF_KWONLY` is used. + `BY_NAME_IF_KWONLY` is used. .. versionadded:: 0.30 @@ -756,7 +756,7 @@ } # `list` - if type_def == list: + if type_def in (list, List): return {"nargs": ZERO_OR_MORE} # `Literal["a", "b"]` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argh-0.31.0/tests/test_typing_hints.py new/argh-0.31.1/tests/test_typing_hints.py --- old/argh-0.31.0/tests/test_typing_hints.py 2023-12-30 19:22:23.325171200 +0100 +++ new/argh-0.31.1/tests/test_typing_hints.py 2024-01-19 17:54:33.588502200 +0100 @@ -34,6 +34,7 @@ guess = TypingHintArgSpecGuesser.typing_hint_to_arg_spec_params assert guess(list) == {"nargs": "*"} + assert guess(List) == {"nargs": "*"} assert guess(Optional[list]) == {"nargs": "*", "required": False} assert guess(List[str]) == {"nargs": "*", "type": str} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argh-0.31.0/tox.ini new/argh-0.31.1/tox.ini --- old/argh-0.31.0/tox.ini 2023-12-30 19:22:23.325171200 +0100 +++ new/argh-0.31.1/tox.ini 2024-01-19 17:54:33.588502200 +0100 @@ -44,7 +44,7 @@ allowlist_externals = rm commands = rm -rf docs/build - sphinx-build source build --color -W --keep-going -n -b html {posargs} + sphinx-build . build --color -W --keep-going -n -b html {posargs} [testenv:lint] description = verify with linters