Changelog¶
7.0.0 (2025-06-15)¶
Dropped support for Python 3.5 and 3.6.
Added the
DEFOPT_DEBUGenvironment variable to help troubleshooting union parser failures.Union members that come after
strorpathlib.Pathno longer need to have a valid parser.Support optional single-item tuples with None parsers.
Support toplevel type aliases created with the
typestatement.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 handdefopt.signatureno longer annotates the return type with the suppressed exceptions, anddefopt.bindonly wraps the returned callable object in an exception suppressor if needed.defopt.signaturenow correctly annotates parameters with no type annotation usinginspect.Parameter.emptyinstead ofNone.defopt.signaturealso accepts docstrings as input.Document
defopt.signatureas provisional APIs.Removed the deprecated
strict_kwonlyin favor ofcli_options.Support
functools.partialto set or overwrite function default values.
6.4.0 (2022-07-19)¶
defopt.bindnow returns a singlefunctools.partialobject representing the call that would be executed bydefopt.run.Added
defopt.bind_knownwhich supports unknown arguments and returns them as a separate list.Document
defopt.bindanddefopt.bind_knownas provisional APIs.Added
intermixed(on Python>=3.7).Support
python -mdefopt package.name:function_name args ...(with a colon).
6.3.0 (2022-02-07)¶
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.
6.2.0 (2021-11-24)¶
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.signatureannotates the return type with the documented raisable exception types.Added
defopt.bindto allow preprocessing arguments before performing the call.Added the ability to use nested subcommands.
6.1.0 (2021-02-25)¶
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 oftyping.Optionaltoo.
6.0.2 (2020-12-08)¶
Don’t get tripped by Attributes sections.
Added support for Python 3.9.
6.0.1 (2020-09-18)¶
Fixed support for container types defaulting to None.
6.0.0 (2020-05-11)¶
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=Noneas a synonym forparsers={}.Added
defopt.signatureto 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
*argsinstead 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.namewas passed todefopt.run.Support more RST constructs: doctest blocks, rubrics (used by Napoleon for sectioning).
5.1.0 (2019-03-01)¶
Added
argparse_kwargs.Fixed short flag generation to avoid collision with
-h.
5.0.0 (2018-10-18)¶
Added default parser for
slice.Removed support for passing multiple functions positionally.
Added support for Python 3.7.
Removed support for Python 3.3.
4.0.1 (2017-11-26)¶
Fixed crash when handing a NamedTuple followed by other arguments
4.0.0 (2017-11-07)¶
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
3.2.0 (2017-05-30)¶
Added
show_typesoption to automatically display variable types (Thanks to @anntzer)Added default parser for
pathlib.Pathwhen it is available (Thanks to @anntzer)Added annotations example to the generated documentation
3.1.1 (2017-04-12)¶
Fixed environment markers in wheels
3.1.0 (2017-04-12)¶
Thanks to @anntzer for contributing the features in this release.
Changed
defopt.runto take multiple functions as a single listDeprecated 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
3.0.0 (2016-12-16)¶
Added support for Python 3.6
Changed keyword-only arguments without defaults to required flags
Added support for all variants of
paramandtypeAdded support for list-typed variable positional arguments
Fixed help message formatting to avoid argparse’s string interpolation
Added __version__ attribute
2.0.1 (2016-09-13)¶
Fixed handling of generic types in Python 3.5.2 (and typing 3.5.2)
2.0.0 (2016-05-10)¶
Added ability to specify short flags
Added automatic
--nameand--no-nameflags for optional booleansAdded automatic translation of underscores to hyphens in all flags
Removed
defopt.parser
1.3.0 (2016-03-21)¶
Added
parsersargument todefopt.runDeprecated
defopt.parser
1.2.0 (2016-02-25)¶
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
1.1.0 (2016-02-21)¶
Added support for Google- and Numpy-style docstrings
Changed
defopt.runto return the value from the called function
1.0.1 (2016-02-14)¶
Added workaround to display raw text of any unparsed element (issue #1)
1.0.0 (2016-02-14)¶
Removed decorator interface and added simpler
defopt.runinterfaceAdded full documentation hosted on Read the Docs
Added more informative exceptions for type lookup failures
Fixed bug where
defopt.parserwas not returning the input functionFixed 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
0.3.1 (2016-02-10)¶
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
0.3.0 (2016-02-10)¶
Added support for Python 2.7
Fixed code that was polluting the logging module’s root logger
0.2.0 (2016-02-09)¶
Added support for combined parameter type and description definitions
Fixed crashing bug when an optional Enum-typed flag wasn’t specified
0.1.0 (2016-02-08)¶
Initial version