- Dropped support for Python 3.5 and 3.6.
- Added the :envvar:`DEFOPT_DEBUG` environment variable to help troubleshooting union parser failures.
- Union members that come after str or pathlib.Path no longer need to have a valid parser.
- Support optional single-item tuples with None parsers.
- Pass-through more Sphinx standard roles.
- Made parsed function docstring available as
signature(...).doc
, and tuple of suppressed exception types assignature(...).raises
. On the other hand defopt.signature no longer annotates the return type with the suppressed exceptions, and defopt.bind only wraps the returned callable object in an exception suppressor if needed. - defopt.signature now correctly annotates parameters with no type annotation
using inspect.Parameter.empty instead of
None
. - defopt.signature also accepts docstrings as input.
- Document defopt.signature as provisional APIs.
- Removed the deprecated
strict_kwonly
in favor ofcli_options
.
- defopt.bind now returns a single functools.partial object representing the call that would be executed by defopt.run.
- Added defopt.bind_known which supports unknown arguments and returns them as a separate list.
- Document defopt.bind and defopt.bind_known as provisional APIs.
- Added
intermixed
(on Python>=3.7). - Support
python -mdefopt package.name:function_name args ...
(with a colon).
- Fixed
typing.Optional[bool]
to still be treated as a flag. - Added support for
tuple[X, ...]
andCollection[X]
(Thanks to @neelmraman). - Disabled syntax highlighting when parsing, thus getting rid of a weak dependency on pygments.
- Tweaked newline handling in help generation.
- Bumped docutils dependency to >=0.12, for setuptools compatibility.
- Added support for Python 3.10, and for
A | B
-style unions (only on that version of Python). - Fixed bad interaction between custom None parsers and tuple parsers.
- Give preference to None parsers in Unions.
- defopt.signature annotates the return type with the documented raisable exception types.
- Added defopt.bind to allow preprocessing arguments before performing the call.
- Added the ability to use nested subcommands.
- Boolean flags are now implemented using a variant of
argparse.BooleanOptionalAction
. - Added
no_negated_flags
. - A custom parser set for
type(None)
now affects parsing of typing.Optional too.
- Don't get tripped by Attributes sections.
- Added support for Python 3.9.
- Fixed support for container types defaulting to None.
- Added support for Union and Literal types.
- Assume that types annotated as constructible from a single str are their own parser.
- Added support for catching exceptions.
- Added support for passing functions as a
{name: function}
mapping (Thanks to @johnfarina). - Removed support for Python<=3.4.
- Disallowed
parsers=None
as a synonym forparsers={}
. - Added defopt.signature to separate the signature-and-docstring parsing from the ArgumentParser construction.
- Fixed removal of comments from help string.
- Added support for
--version
. - Fixed displaying of defaults for parameters with no help, and added
show_defaults
. - Support varargs documented under
*args
instead ofargs
. - Support standard Sphinx roles in the Python domain (
:py:func:
,:func:
, etc.); they are just stripped out. - Arbitrary type-hinted functions can now by run with
python -mdefopt dotted.name args ...
, as ifdotted.name
was passed to defopt.run. - Support more RST constructs: doctest blocks, rubrics (used by Napoleon for sectioning).
- Added
argparse_kwargs
. - Fixed short flag generation to avoid collision with
-h
.
- Added default parser for slice.
- Removed support for passing multiple functions positionally.
- Added support for Python 3.7.
- Removed support for Python 3.3.
- Fixed crash when handing a NamedTuple followed by other arguments
- Changed parser generation to only make flags from keyword-only arguments, treating arguments with defaults as optional positionals
- Changed subparser generation to replace dashes in names with underscores
- Added support for RST lists
- Added support for typed Tuple and NamedTuple arguments
- Added __all__
- Ignored arguments whose names start with underscores
- Added
show_types
option to automatically display variable types (Thanks to @anntzer) - Added default parser for pathlib.Path when it is available (Thanks to @anntzer)
- Added annotations example to the generated documentation
- Fixed environment markers in wheels
Thanks to @anntzer for contributing the features in this release.
- Changed defopt.run to take multiple functions as a single list
- Deprecated passing multiple functions positionally
- Added subcommand summaries to the help message for multiple functions
- Added automatic short flags where they are unambiguous
- Added rendering of italic, bold and underlined text from docstrings
- Added Python 3.6 classifier to setup.py
- Dropped nose as a test runner
- Added support for Python 3.6
- Changed keyword-only arguments without defaults to required flags
- Added support for all variants of
param
andtype
- Added support for list-typed variable positional arguments
- Fixed help message formatting to avoid argparse's string interpolation
- Added __version__ attribute
- Fixed handling of generic types in Python 3.5.2 (and typing 3.5.2)
- Added ability to specify short flags
- Added automatic
--name
and--no-name
flags for optional booleans - Added automatic translation of underscores to hyphens in all flags
- Removed
defopt.parser
- Added
parsers
argument to defopt.run - Deprecated
defopt.parser
- Added support for type annotations
- Added parameter defaults to help text
- Removed default line wrapping of help text
- Added '1' and '0' as accepted values for True and False respectively
- Added support for Google- and Numpy-style docstrings
- Changed defopt.run to return the value from the called function
- Added workaround to display raw text of any unparsed element (issue #1)
- Removed decorator interface and added simpler defopt.run interface
- Added full documentation hosted on Read the Docs
- Added more informative exceptions for type lookup failures
- Fixed bug where
defopt.parser
was not returning the input function - Fixed type lookups to occur in each respective function's global namespace
- Fixed bug where subcommands did not properly parse Enums
- Fixed Enum handling to display members in the order they were defined
- Added support for docstrings that only contain parameter information
- Added more informative exceptions for insufficiently documented functions
- Fixed type parsing bug on Python 2 when future is installed
- Switched to building universal wheels
- Added support for Python 2.7
- Fixed code that was polluting the logging module's root logger
- Added support for combined parameter type and description definitions
- Fixed crashing bug when an optional Enum-typed flag wasn't specified
- Initial version