From 777f7bae0db1aa06537e809ebea19cad9597a024 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Thu, 2 May 2019 11:28:57 +0100 Subject: [PATCH] lisa: Use inspect.getdoc() instead of textwrap.dedent inspect.getdoc()/cleandoc() are better suited to handle docstrings than textwrap.dedent(), since they handle properly lack of indentation on the first line. --- lisa/conf.py | 2 +- lisa/tests/base.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lisa/conf.py b/lisa/conf.py index e596f1c27..4564e615d 100644 --- a/lisa/conf.py +++ b/lisa/conf.py @@ -1148,7 +1148,7 @@ class ConfigurableMeta(abc.ABCMeta): # Update the docstring by using the configuration help docstring = inspect.getdoc(new_cls) if docstring: - new_cls.__doc__ = textwrap.dedent(docstring).format( + new_cls.__doc__ = docstring.format( configurable_params=new_cls._get_rst_param_doc() ) diff --git a/lisa/tests/base.py b/lisa/tests/base.py index c75cf4697..86a8bb9a5 100644 --- a/lisa/tests/base.py +++ b/lisa/tests/base.py @@ -625,7 +625,7 @@ class RTATestBundle(TestBundle, metaclass=RTATestBundleMeta): ) # Make it obvious in the doc where the extra parameters come from - merged_doc = textwrap.dedent(cls.test_noisy_tasks.__doc__).splitlines() + merged_doc = inspect.getdoc(cls.test_noisy_tasks.__doc__).splitlines() # Replace the one-liner func description merged_doc[1] = textwrap.dedent( """ @@ -637,8 +637,8 @@ class RTATestBundle(TestBundle, metaclass=RTATestBundleMeta): """.format(cls.__module__, cls.__name__, cls.check_noisy_tasks.__name__) ) - #pylint: disable=no-member - wrapper.__doc__ = textwrap.dedent(wrapper.__doc__) + "\n".join(merged_doc) + wrapper_doc = inspect.getdoc(wrapper) or '' + wrapper.__doc__ = wrapper_doc + "\n".join(merged_doc) return wrapper return decorator -- GitLab