summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2023-02-07 16:36:29 -0800
committerGitHub <noreply@github.com>2023-02-07 16:36:29 -0800
commit716631189cb5a3f66b3add98f39e64e98bc17bf7 (patch)
tree4dca3d9fccacb02895f538ef9fab68e45609560a /lib
parent02f6e4053466b86e75ea07615c5cc90710cf1257 (diff)
downloadansible-716631189cb5a3f66b3add98f39e64e98bc17bf7.tar.gz
Fix "pointless" strings detected by pylint (#79943)
Convert these strings to comments, since they are not valid docstrings.
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/module_utils/common/text/formatters.py2
-rw-r--r--lib/ansible/module_utils/facts/hardware/sunos.py4
-rw-r--r--lib/ansible/module_utils/facts/network/fc_wwn.py10
-rw-r--r--lib/ansible/module_utils/urls.py2
-rw-r--r--lib/ansible/modules/git.py4
-rw-r--r--lib/ansible/modules/systemd_service.py2
-rw-r--r--lib/ansible/modules/yum.py63
-rw-r--r--lib/ansible/plugins/callback/__init__.py2
-rw-r--r--lib/ansible/plugins/lookup/pipe.py16
9 files changed, 47 insertions, 58 deletions
diff --git a/lib/ansible/module_utils/common/text/formatters.py b/lib/ansible/module_utils/common/text/formatters.py
index 94ca5a3d2a..0c3d495110 100644
--- a/lib/ansible/module_utils/common/text/formatters.py
+++ b/lib/ansible/module_utils/common/text/formatters.py
@@ -67,7 +67,7 @@ def human_to_bytes(number, default_unit=None, isbits=False):
unit = default_unit
if unit is None:
- ''' No unit given, returning raw number '''
+ # No unit given, returning raw number
return int(round(num))
range_key = unit[0].upper()
try:
diff --git a/lib/ansible/module_utils/facts/hardware/sunos.py b/lib/ansible/module_utils/facts/hardware/sunos.py
index 0a77db0799..54850fe3bd 100644
--- a/lib/ansible/module_utils/facts/hardware/sunos.py
+++ b/lib/ansible/module_utils/facts/hardware/sunos.py
@@ -175,9 +175,7 @@ class SunOSHardware(Hardware):
prtdiag_path = self.module.get_bin_path("prtdiag", opt_dirs=[platform_sbin])
rc, out, err = self.module.run_command(prtdiag_path)
- """
- rc returns 1
- """
+ # rc returns 1
if out:
system_conf = out.split('\n')[0]
diff --git a/lib/ansible/module_utils/facts/network/fc_wwn.py b/lib/ansible/module_utils/facts/network/fc_wwn.py
index 86182f8934..dc2e3d6cf9 100644
--- a/lib/ansible/module_utils/facts/network/fc_wwn.py
+++ b/lib/ansible/module_utils/facts/network/fc_wwn.py
@@ -46,18 +46,14 @@ class FcWwnInitiatorFactCollector(BaseFactCollector):
for line in get_file_lines(fcfile):
fc_facts['fibre_channel_wwn'].append(line.rstrip()[2:])
elif sys.platform.startswith('sunos'):
- """
- on solaris 10 or solaris 11 should use `fcinfo hba-port`
- TBD (not implemented): on solaris 9 use `prtconf -pv`
- """
+ # on solaris 10 or solaris 11 should use `fcinfo hba-port`
+ # TBD (not implemented): on solaris 9 use `prtconf -pv`
cmd = module.get_bin_path('fcinfo')
if cmd:
cmd = cmd + " hba-port"
rc, fcinfo_out, err = module.run_command(cmd)
- """
# fcinfo hba-port | grep "Port WWN"
- HBA Port WWN: 10000090fa1658de
- """
+ # HBA Port WWN: 10000090fa1658de
if rc == 0 and fcinfo_out:
for line in fcinfo_out.splitlines():
if 'Port WWN' in line:
diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py
index 958d5a9b75..e28b91b1b4 100644
--- a/lib/ansible/module_utils/urls.py
+++ b/lib/ansible/module_utils/urls.py
@@ -288,7 +288,7 @@ if not HAS_MATCH_HOSTNAME:
# The following block of code is under the terms and conditions of the
# Python Software Foundation License
- """The match_hostname() function from Python 3.4, essential when using SSL."""
+ # The match_hostname() function from Python 3.4, essential when using SSL.
try:
# Divergence: Python-3.7+'s _ssl has this exception type but older Pythons do not
diff --git a/lib/ansible/modules/git.py b/lib/ansible/modules/git.py
index f24e415390..2ea64fb3a1 100644
--- a/lib/ansible/modules/git.py
+++ b/lib/ansible/modules/git.py
@@ -826,7 +826,7 @@ def get_head_branch(git_path, module, dest, remote, bare=False):
repo_path = get_repo_path(dest, bare)
except (IOError, ValueError) as err:
# No repo path found
- """``.git`` file does not have a valid format for detached Git dir."""
+ # ``.git`` file does not have a valid format for detached Git dir.
module.fail_json(
msg='Current repo does not have a valid reference to a '
'separate Git dir or it refers to the invalid path',
@@ -1283,7 +1283,7 @@ def main():
repo_path = separate_git_dir
except (IOError, ValueError) as err:
# No repo path found
- """``.git`` file does not have a valid format for detached Git dir."""
+ # ``.git`` file does not have a valid format for detached Git dir.
module.fail_json(
msg='Current repo does not have a valid reference to a '
'separate Git dir or it refers to the invalid path',
diff --git a/lib/ansible/modules/systemd_service.py b/lib/ansible/modules/systemd_service.py
index 0805bfcecf..bad29bba67 100644
--- a/lib/ansible/modules/systemd_service.py
+++ b/lib/ansible/modules/systemd_service.py
@@ -367,7 +367,7 @@ def main():
if os.getenv('XDG_RUNTIME_DIR') is None:
os.environ['XDG_RUNTIME_DIR'] = '/run/user/%s' % os.geteuid()
- ''' Set CLI options depending on params '''
+ # Set CLI options depending on params
# if scope is 'system' or None, we can ignore as there is no extra switch.
# The other choices match the corresponding switch
if module.params['scope'] != 'system':
diff --git a/lib/ansible/modules/yum.py b/lib/ansible/modules/yum.py
index 2e035fcb12..dddc47cc76 100644
--- a/lib/ansible/modules/yum.py
+++ b/lib/ansible/modules/yum.py
@@ -1283,15 +1283,13 @@ class YumModule(YumDnf):
obsoletes = {}
for line in out.split('\n'):
line = line.split()
- """
- Ignore irrelevant lines:
- - '*' in line matches lines like mirror lists: "* base: mirror.corbina.net"
- - len(line) != 3 or 6 could be strings like:
- "This system is not registered with an entitlement server..."
- - len(line) = 6 is package obsoletes
- - checking for '.' in line[0] (package name) likely ensures that it is of format:
- "package_name.arch" (coreutils.x86_64)
- """
+ # Ignore irrelevant lines:
+ # - '*' in line matches lines like mirror lists: "* base: mirror.corbina.net"
+ # - len(line) != 3 or 6 could be strings like:
+ # "This system is not registered with an entitlement server..."
+ # - len(line) = 6 is package obsoletes
+ # - checking for '.' in line[0] (package name) likely ensures that it is of format:
+ # "package_name.arch" (coreutils.x86_64)
if '*' in line or len(line) not in [3, 6] or '.' not in line[0]:
continue
@@ -1620,30 +1618,29 @@ class YumModule(YumDnf):
self.yum_basecmd.extend(e_cmd)
if self.state in ('installed', 'present', 'latest'):
- """ The need of this entire if conditional has to be changed
- this function is the ensure function that is called
- in the main section.
-
- This conditional tends to disable/enable repo for
- install present latest action, same actually
- can be done for remove and absent action
-
- As solution I would advice to cal
- try: self.yum_base.repos.disableRepo(disablerepo)
- and
- try: self.yum_base.repos.enableRepo(enablerepo)
- right before any yum_cmd is actually called regardless
- of yum action.
-
- Please note that enable/disablerepo options are general
- options, this means that we can call those with any action
- option. https://linux.die.net/man/8/yum
-
- This docstring will be removed together when issue: #21619
- will be solved.
-
- This has been triggered by: #19587
- """
+ # The need of this entire if conditional has to be changed
+ # this function is the ensure function that is called
+ # in the main section.
+ #
+ # This conditional tends to disable/enable repo for
+ # install present latest action, same actually
+ # can be done for remove and absent action
+ #
+ # As solution I would advice to cal
+ # try: self.yum_base.repos.disableRepo(disablerepo)
+ # and
+ # try: self.yum_base.repos.enableRepo(enablerepo)
+ # right before any yum_cmd is actually called regardless
+ # of yum action.
+ #
+ # Please note that enable/disablerepo options are general
+ # options, this means that we can call those with any action
+ # option. https://linux.die.net/man/8/yum
+ #
+ # This docstring will be removed together when issue: #21619
+ # will be solved.
+ #
+ # This has been triggered by: #19587
if self.update_cache:
self.module.run_command(self.yum_basecmd + ['clean', 'expire-cache'])
diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py
index d4fc347d03..c812b23193 100644
--- a/lib/ansible/plugins/callback/__init__.py
+++ b/lib/ansible/plugins/callback/__init__.py
@@ -163,7 +163,7 @@ class CallbackBase(AnsiblePlugin):
self._hide_in_debug = ('changed', 'failed', 'skipped', 'invocation', 'skip_reason')
- ''' helper for callbacks, so they don't all have to include deepcopy '''
+ # helper for callbacks, so they don't all have to include deepcopy
_copy_result = deepcopy
def set_option(self, k, v):
diff --git a/lib/ansible/plugins/lookup/pipe.py b/lib/ansible/plugins/lookup/pipe.py
index 54df3fc078..a9318a1962 100644
--- a/lib/ansible/plugins/lookup/pipe.py
+++ b/lib/ansible/plugins/lookup/pipe.py
@@ -56,15 +56,13 @@ class LookupModule(LookupBase):
ret = []
for term in terms:
- '''
- https://docs.python.org/3/library/subprocess.html#popen-constructor
-
- The shell argument (which defaults to False) specifies whether to use the
- shell as the program to execute. If shell is True, it is recommended to pass
- args as a string rather than as a sequence
-
- https://github.com/ansible/ansible/issues/6550
- '''
+ # https://docs.python.org/3/library/subprocess.html#popen-constructor
+ #
+ # The shell argument (which defaults to False) specifies whether to use the
+ # shell as the program to execute. If shell is True, it is recommended to pass
+ # args as a string rather than as a sequence
+ #
+ # https://github.com/ansible/ansible/issues/6550
term = str(term)
p = subprocess.Popen(term, cwd=self._loader.get_basedir(), shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)