From 7111d4b6fa321e9fe3e127f01e9bd28c87eb03a6 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 12 Dec 2024 12:57:09 +0100 Subject: [PATCH] Applying flake8 rules --- plugins/test/tests.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/plugins/test/tests.py b/plugins/test/tests.py index 112ad4b..f87b1e5 100644 --- a/plugins/test/tests.py +++ b/plugins/test/tests.py @@ -1,5 +1,13 @@ -# Copyright (c) 2020 Matthias Dellweg -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +@summary: Ansible module for different test functions. + +@author: Matthias Dellweg + Frank Brehm +@contact: frank@brehm-online.com +@copyright: © 2020 Matthias Dellweg +""" import typing as t @@ -7,31 +15,35 @@ import typing as t from jinja2.runtime import Undefined +# ============================================================================= def empty_test(value: t.Any) -> bool: - """ - Check whether a value is false or an empty string, list or dict. - """ + """Check whether a value is false or an empty string, list or dict.""" if isinstance(value, Undefined): return True if isinstance(value, bool): return not value if value is None: return True - if value == "": + if value == '': return True if value == []: return True if value == {}: return True - if value == b"": + if value == b'': return True return False +# ============================================================================= class TestModule: + """A test module object.""" + + # ------------------ def tests(self) -> t.Dict[str, t.Callable]: + """Return all usable test functions and methods from this module.""" return { - "empty": empty_test, + 'empty': empty_test, } -# last line +# vim: ts=4 et list -- 2.39.5