semvec/pypi-packages huggingface dataset:
decopts 1.0.2
Use decorators for dealing with argparse
License: MIT
Keywords: optparse argparse

Installation
============

::

    pip install decparse

Usage
=====

Before with argeparse

.. code:: python

    import argparse

    parser = argparse.ArgumentParser(
        prog='foo',
        description='Print bar',
        add_help=True
    )
    parser.add_argument(
        '--baz',
        action='store_true'
        help='Also print baz'
    )
    args = parser.parse_arguments()

    print('bar')
    if args.baz:
        print('baz')

Using decopts instead

.. code:: python

    from decopts import entrypoint, option

    @entrypoint(
        prog='foo',
        description='Print bar',
        add_help=True
    )
    @option(
        '--baz',
        action='store_true'
        help='Also print baz'
    )
    def main():
        print('bar')
        if main.args.baz:
            print('baz')

    main()

Adding subcommands

.. code:: python

    from decopts import entrypoint, option, action

    @entrypoint(
        prog='foo',
        description='Print something',
        add_help=True
    )
    def main():
        return

    @action(
        main,
        'foo',
        description='Print foo'
    )
    def foo():
        print('foo')

    @action(
        main,
        'baz',
        description='Print baz'
    )
    def baz():
        print('baz')

    main()
coverage_filter 0.0.0
Coverage filter
License: MIT
Keywords: unit test coverage

Coverage filter
===============

Allows developers to indicate which code they are trying to test when using
coverage tools.

**Warning** This is just a proof of concept. The API will likely change as I 
receive feedback. There are also no unit tests, or other code quality control
methods in place.  If you wish to use this code, please make a copy for 
yourself, so my changes won't break your build.


Example
=======

Example code to be tested: (in ``target.py``)

.. code-block::

    def target(self):
        return target_inner()
    
    def target_inner(self):
        return 42


Example unit test: (in ``test_target.py``)

.. code-block::

    from coverage_filter import CoverageFilter
    from target import target
    
    @CoverageFilter('target.py:target')
    def test_target(self):   
        assert target() == 42


For more information, check out my blog on the topic.