Fix: bt2: _trim_docstring(): docstring can have 0 or 1 line
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 10 Sep 2020 20:47:52 +0000 (16:47 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Dec 2020 17:10:16 +0000 (12:10 -0500)
commite30908cfe5b1a65d01c52cf21e7134abf9697eaf
tree560570e294d9938638cafc78819fe1a8ddb91e0b
parent0e32706b330840cf012f97884a4c22ea34f278b4
Fix: bt2: _trim_docstring(): docstring can have 0 or 1 line

It is possible that a user component class's docstring has no lines or a
single one, for example:

    # no line
    class MySink(bt2._UserSinkComponent):
        """"""

        def _user_consume(self):
            pass

    # single line
    class MySink(bt2._UserSinkComponent):
        """The single line"""

        def _user_consume(self):
            pass

The previous version of _trim_docstring() expects this format:

    class MySink(bt2._UserSinkComponent):
        """
        My sink's description

        Dolore officia ex et aliquip eiusmod enim pariatur reprehenderit
        ad adipisicing non occaecat ullamco aliquip laborum duis
        proident ex duis.

        Irure commodo proident esse non pariatur in aute cillum id aute.
        """

        def _user_consume(self):
            pass

In _trim_docstring(), accept no lines or a single one.

Adding new tests to `test_component_class.py` to validate this
behaviour. The

    # fmt: off
    """
    """
    # fmt: on

docstring has off/on formatting markers as Black 20.8b1 transforms this
into the non-equivalent

    """"""

(which is another test now).

In addition, reformat Python files with Black v20.8b1, so that the
pylint CI job passes.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia12b0e9bfd4d1e1aaa86f0c8c207c3c1535f5c3e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4072
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4525
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/bindings/python/bt2/bt2/__init__.py
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/error.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/trace_class.py
tests/bindings/python/bt2/test_component_class.py
tests/bindings/python/bt2/test_event.py
tests/bindings/python/bt2/test_message.py
This page took 0.025236 seconds and 4 git commands to generate.