From 02f6e4053466b86e75ea07615c5cc90710cf1257 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 7 Feb 2023 14:46:33 -0800 Subject: [PATCH] Clean up pointless statements (#79941) * Add ignores for intentional pointless statements * Remove redundant docstring * Fix function docstring placement --- lib/ansible/module_utils/urls.py | 2 +- lib/ansible/modules/yum.py | 2 +- lib/ansible/plugins/cliconf/__init__.py | 1 - lib/ansible/plugins/filter/core.py | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py index 9d0f7d5c4fb..958d5a9b75f 100644 --- a/lib/ansible/module_utils/urls.py +++ b/lib/ansible/module_utils/urls.py @@ -160,7 +160,7 @@ if not HAS_SSLCONTEXT and HAS_SSL: libssl = ctypes.CDLL(libssl_name) for method in ('TLSv1_1_method', 'TLSv1_2_method'): try: - libssl[method] + libssl[method] # pylint: disable=pointless-statement # Found something - we'll let openssl autonegotiate and hope # the server has disabled sslv2 and 3. best we can do. PROTOCOL = ssl.PROTOCOL_SSLv23 diff --git a/lib/ansible/modules/yum.py b/lib/ansible/modules/yum.py index cb48789d066..2e035fcb128 100644 --- a/lib/ansible/modules/yum.py +++ b/lib/ansible/modules/yum.py @@ -568,7 +568,7 @@ class YumModule(YumDnf): # A sideeffect of accessing conf is that the configuration is # loaded and plugins are discovered - self.yum_base.conf + self.yum_base.conf # pylint: disable=pointless-statement try: for rid in self.disablerepo: diff --git a/lib/ansible/plugins/cliconf/__init__.py b/lib/ansible/plugins/cliconf/__init__.py index be0f23eb42c..a79bcae04c9 100644 --- a/lib/ansible/plugins/cliconf/__init__.py +++ b/lib/ansible/plugins/cliconf/__init__.py @@ -360,7 +360,6 @@ class CliconfBase(AnsiblePlugin): remote host before triggering timeout exception :return: None """ - """Fetch file over scp/sftp from remote device""" ssh = self._connection.paramiko_conn._connect_uncached() if proto == 'scp': if not HAS_SCP: diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index 1e0c835ae77..5906408fa70 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -192,8 +192,8 @@ def ternary(value, true_val, false_val, none_val=None): def regex_escape(string, re_type='python'): + """Escape all regular expressions special characters from STRING.""" string = to_text(string, errors='surrogate_or_strict', nonstring='simplerepr') - '''Escape all regular expressions special characters from STRING.''' if re_type == 'python': return re.escape(string) elif re_type == 'posix_basic': @@ -299,9 +299,9 @@ def to_uuid(string, namespace=UUID_NAMESPACE_ANSIBLE): def mandatory(a, msg=None): + """Make a variable mandatory.""" from jinja2.runtime import Undefined - ''' Make a variable mandatory ''' if isinstance(a, Undefined): if a._undefined_name is not None: name = "'%s' " % to_text(a._undefined_name)