Sanity Fixes: (#80953)

* Typo fixes
* arguments-renamed
* pep8:E501
* pylint:use-a-generator
* pep8:E231
* use-argspec-type-path

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/80993/head
Abhijeet Kasurde 2 years ago committed by GitHub
parent 090a5cdfcf
commit fda66eeee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -865,7 +865,7 @@ def RedirectHandlerFactory(follow_redirects=None, validate_certs=True, ca_path=N
to determine how redirects should be handled in urllib2. to determine how redirects should be handled in urllib2.
""" """
def redirect_request(self, req, fp, code, msg, hdrs, newurl): def redirect_request(self, req, fp, code, msg, headers, newurl):
if not any((HAS_SSLCONTEXT, HAS_URLLIB3_PYOPENSSLCONTEXT)): if not any((HAS_SSLCONTEXT, HAS_URLLIB3_PYOPENSSLCONTEXT)):
handler = maybe_add_ssl_handler(newurl, validate_certs, ca_path=ca_path, ciphers=ciphers) handler = maybe_add_ssl_handler(newurl, validate_certs, ca_path=ca_path, ciphers=ciphers)
if handler: if handler:
@ -873,23 +873,23 @@ def RedirectHandlerFactory(follow_redirects=None, validate_certs=True, ca_path=N
# Preserve urllib2 compatibility # Preserve urllib2 compatibility
if follow_redirects == 'urllib2': if follow_redirects == 'urllib2':
return urllib_request.HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, hdrs, newurl) return urllib_request.HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, headers, newurl)
# Handle disabled redirects # Handle disabled redirects
elif follow_redirects in ['no', 'none', False]: elif follow_redirects in ['no', 'none', False]:
raise urllib_error.HTTPError(newurl, code, msg, hdrs, fp) raise urllib_error.HTTPError(newurl, code, msg, headers, fp)
method = req.get_method() method = req.get_method()
# Handle non-redirect HTTP status or invalid follow_redirects # Handle non-redirect HTTP status or invalid follow_redirects
if follow_redirects in ['all', 'yes', True]: if follow_redirects in ['all', 'yes', True]:
if code < 300 or code >= 400: if code < 300 or code >= 400:
raise urllib_error.HTTPError(req.get_full_url(), code, msg, hdrs, fp) raise urllib_error.HTTPError(req.get_full_url(), code, msg, headers, fp)
elif follow_redirects == 'safe': elif follow_redirects == 'safe':
if code < 300 or code >= 400 or method not in ('GET', 'HEAD'): if code < 300 or code >= 400 or method not in ('GET', 'HEAD'):
raise urllib_error.HTTPError(req.get_full_url(), code, msg, hdrs, fp) raise urllib_error.HTTPError(req.get_full_url(), code, msg, headers, fp)
else: else:
raise urllib_error.HTTPError(req.get_full_url(), code, msg, hdrs, fp) raise urllib_error.HTTPError(req.get_full_url(), code, msg, headers, fp)
try: try:
# Python 2-3.3 # Python 2-3.3
@ -906,11 +906,11 @@ def RedirectHandlerFactory(follow_redirects=None, validate_certs=True, ca_path=N
# Support redirect with payload and original headers # Support redirect with payload and original headers
if code in (307, 308): if code in (307, 308):
# Preserve payload and headers # Preserve payload and headers
headers = req.headers req_headers = req.headers
else: else:
# Do not preserve payload and filter headers # Do not preserve payload and filter headers
data = None data = None
headers = dict((k, v) for k, v in req.headers.items() req_headers = dict((k, v) for k, v in req.headers.items()
if k.lower() not in ("content-length", "content-type", "transfer-encoding")) if k.lower() not in ("content-length", "content-type", "transfer-encoding"))
# http://tools.ietf.org/html/rfc7231#section-6.4.4 # http://tools.ietf.org/html/rfc7231#section-6.4.4
@ -928,7 +928,7 @@ def RedirectHandlerFactory(follow_redirects=None, validate_certs=True, ca_path=N
return RequestWithMethod(newurl, return RequestWithMethod(newurl,
method=method, method=method,
headers=headers, headers=req_headers,
data=data, data=data,
origin_req_host=origin_req_host, origin_req_host=origin_req_host,
unverifiable=True, unverifiable=True,

@ -124,8 +124,7 @@ def main():
async_dir = module.params['_async_dir'] async_dir = module.params['_async_dir']
# setup logging directory # setup logging directory
logdir = os.path.expanduser(async_dir) log_path = os.path.join(async_dir, jid)
log_path = os.path.join(logdir, jid)
if not os.path.exists(log_path): if not os.path.exists(log_path):
module.fail_json(msg="could not find job", ansible_job_id=jid, started=1, finished=1) module.fail_json(msg="could not find job", ansible_job_id=jid, started=1, finished=1)

@ -48,7 +48,7 @@ class PlaybookInclude(Base, Conditional, Taggable):
def load(data, basedir, variable_manager=None, loader=None): def load(data, basedir, variable_manager=None, loader=None):
return PlaybookInclude().load_data(ds=data, basedir=basedir, variable_manager=variable_manager, loader=loader) return PlaybookInclude().load_data(ds=data, basedir=basedir, variable_manager=variable_manager, loader=loader)
def load_data(self, ds, basedir, variable_manager=None, loader=None): def load_data(self, ds, variable_manager=None, loader=None, basedir=None):
''' '''
Overrides the base load_data(), as we're actually going to return a new Overrides the base load_data(), as we're actually going to return a new
Playbook() object rather than a PlaybookInclude object Playbook() object rather than a PlaybookInclude object

@ -41,7 +41,7 @@ from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase): class LookupModule(LookupBase):
def run(self, terms, inject=None, **kwargs): def run(self, terms, variables=None, **kwargs):
ret = terms ret = terms
if terms: if terms:

@ -34,24 +34,24 @@ class ShellModule(PSShellModule):
# Used by various parts of Ansible to do Windows specific changes # Used by various parts of Ansible to do Windows specific changes
_IS_WINDOWS = True _IS_WINDOWS = True
def quote(self, s): def quote(self, cmd):
# cmd does not support single quotes that the shlex_quote uses. We need to override the quoting behaviour to # cmd does not support single quotes that the shlex_quote uses. We need to override the quoting behaviour to
# better match cmd.exe. # better match cmd.exe.
# https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/ # https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
# Return an empty argument # Return an empty argument
if not s: if not cmd:
return '""' return '""'
if _find_unsafe(s) is None: if _find_unsafe(cmd) is None:
return s return cmd
# Escape the metachars as we are quoting the string to stop cmd from interpreting that metachar. For example # Escape the metachars as we are quoting the string to stop cmd from interpreting that metachar. For example
# 'file &whoami.exe' would result in 'file $(whoami.exe)' instead of the literal string # 'file &whoami.exe' would result in 'file $(whoami.exe)' instead of the literal string
# https://stackoverflow.com/questions/3411771/multiple-character-replace-with-python # https://stackoverflow.com/questions/3411771/multiple-character-replace-with-python
for c in '^()%!"<>&|': # '^' must be the first char that we scan and replace for c in '^()%!"<>&|': # '^' must be the first char that we scan and replace
if c in s: if c in cmd:
# I can't find any docs that explicitly say this but to escape ", it needs to be prefixed with \^. # I can't find any docs that explicitly say this but to escape ", it needs to be prefixed with \^.
s = s.replace(c, ("\\^" if c == '"' else "^") + c) cmd = cmd.replace(c, ("\\^" if c == '"' else "^") + c)
return '^"' + s + '^"' return '^"' + cmd + '^"'

@ -19,7 +19,7 @@ DOCUMENTATION:
type: boolean type: boolean
default: False default: False
multiline: multiline:
description: Match against mulitple lines in string. description: Match against multiple lines in string.
type: boolean type: boolean
default: False default: False
EXAMPLES: | EXAMPLES: |

@ -18,7 +18,7 @@ DOCUMENTATION:
type: boolean type: boolean
default: False default: False
multiline: multiline:
description: Match against mulitple lines in string. description: Match against multiple lines in string.
type: boolean type: boolean
default: False default: False

@ -22,7 +22,6 @@ lib/ansible/keyword_desc.yml no-unwanted-files
lib/ansible/modules/apt.py validate-modules:parameter-invalid lib/ansible/modules/apt.py validate-modules:parameter-invalid
lib/ansible/modules/apt_repository.py validate-modules:parameter-invalid lib/ansible/modules/apt_repository.py validate-modules:parameter-invalid
lib/ansible/modules/assemble.py validate-modules:nonexistent-parameter-documented lib/ansible/modules/assemble.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/async_status.py use-argspec-type-path
lib/ansible/modules/async_status.py validate-modules!skip lib/ansible/modules/async_status.py validate-modules!skip
lib/ansible/modules/async_wrapper.py ansible-doc!skip # not an actual module lib/ansible/modules/async_wrapper.py ansible-doc!skip # not an actual module
lib/ansible/modules/async_wrapper.py pylint:ansible-bad-function # ignore, required lib/ansible/modules/async_wrapper.py pylint:ansible-bad-function # ignore, required
@ -93,19 +92,15 @@ lib/ansible/module_utils/six/__init__.py no-dict-itervalues
lib/ansible/module_utils/six/__init__.py pylint:self-assigning-variable lib/ansible/module_utils/six/__init__.py pylint:self-assigning-variable
lib/ansible/module_utils/six/__init__.py pylint:trailing-comma-tuple lib/ansible/module_utils/six/__init__.py pylint:trailing-comma-tuple
lib/ansible/module_utils/six/__init__.py replace-urlopen lib/ansible/module_utils/six/__init__.py replace-urlopen
lib/ansible/module_utils/urls.py pylint:arguments-renamed
lib/ansible/module_utils/urls.py replace-urlopen lib/ansible/module_utils/urls.py replace-urlopen
lib/ansible/parsing/yaml/objects.py pylint:arguments-renamed lib/ansible/parsing/yaml/objects.py pylint:arguments-renamed
lib/ansible/playbook/collectionsearch.py required-and-default-attributes # https://github.com/ansible/ansible/issues/61460 lib/ansible/playbook/collectionsearch.py required-and-default-attributes # https://github.com/ansible/ansible/issues/61460
lib/ansible/playbook/playbook_include.py pylint:arguments-renamed
lib/ansible/playbook/role/include.py pylint:arguments-renamed lib/ansible/playbook/role/include.py pylint:arguments-renamed
lib/ansible/plugins/action/normal.py action-plugin-docs # default action plugin for modules without a dedicated action plugin lib/ansible/plugins/action/normal.py action-plugin-docs # default action plugin for modules without a dedicated action plugin
lib/ansible/plugins/cache/base.py ansible-doc!skip # not a plugin, but a stub for backwards compatibility lib/ansible/plugins/cache/base.py ansible-doc!skip # not a plugin, but a stub for backwards compatibility
lib/ansible/plugins/callback/__init__.py pylint:arguments-renamed lib/ansible/plugins/callback/__init__.py pylint:arguments-renamed
lib/ansible/plugins/inventory/advanced_host_list.py pylint:arguments-renamed lib/ansible/plugins/inventory/advanced_host_list.py pylint:arguments-renamed
lib/ansible/plugins/inventory/host_list.py pylint:arguments-renamed lib/ansible/plugins/inventory/host_list.py pylint:arguments-renamed
lib/ansible/plugins/lookup/random_choice.py pylint:arguments-renamed
lib/ansible/plugins/shell/cmd.py pylint:arguments-renamed
lib/ansible/utils/collection_loader/_collection_finder.py pylint:deprecated-class lib/ansible/utils/collection_loader/_collection_finder.py pylint:deprecated-class
lib/ansible/utils/collection_loader/_collection_meta.py pylint:deprecated-class lib/ansible/utils/collection_loader/_collection_meta.py pylint:deprecated-class
test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py pylint:ansible-bad-function # ignore, required for testing test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py pylint:ansible-bad-function # ignore, required for testing
@ -157,11 +152,8 @@ test/lib/ansible_test/_data/requirements/sanity.pslint.ps1 pslint:PSCustomUseLit
test/lib/ansible_test/_util/target/setup/ConfigureRemotingForAnsible.ps1 pslint:PSCustomUseLiteralPath test/lib/ansible_test/_util/target/setup/ConfigureRemotingForAnsible.ps1 pslint:PSCustomUseLiteralPath
test/lib/ansible_test/_util/target/setup/requirements.py replace-urlopen test/lib/ansible_test/_util/target/setup/requirements.py replace-urlopen
test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py no-unicode-literals test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py no-unicode-literals
test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py pylint:use-a-generator
test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py pylint:arguments-renamed test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py pylint:arguments-renamed
test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_config.py pep8:E501
test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py pylint:arguments-renamed test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py pylint:arguments-renamed
test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py pep8:E231
test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/module_utils/WebRequest.psm1 pslint!skip test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/module_utils/WebRequest.psm1 pslint!skip
test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/modules/win_uri.ps1 pslint!skip test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/modules/win_uri.ps1 pslint!skip
test/support/windows-integration/plugins/modules/async_status.ps1 pslint!skip test/support/windows-integration/plugins/modules/async_status.ps1 pslint!skip

@ -593,7 +593,7 @@ def remove_empties(cfg_dict):
elif ( elif (
isinstance(val, list) isinstance(val, list)
and val and val
and all([isinstance(x, dict) for x in val]) and all(isinstance(x, dict) for x in val)
): ):
child_val = [remove_empties(x) for x in val] child_val = [remove_empties(x) for x in val]
if child_val: if child_val:

@ -34,7 +34,8 @@ extends_documentation_fragment:
- cisco.ios.ios - cisco.ios.ios
notes: notes:
- Tested against IOS 15.6 - Tested against IOS 15.6
- Abbreviated commands are NOT idempotent, see L(Network FAQ,../network/user_guide/faq.html#why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands). - Abbreviated commands are NOT idempotent,
see L(Network FAQ,../network/user_guide/faq.html#why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands).
options: options:
lines: lines:
description: description:

@ -213,7 +213,7 @@ def main():
module.fail_json(msg=msg, failed_conditions=failed_conditions) module.fail_json(msg=msg, failed_conditions=failed_conditions)
result.update( result.update(
{"stdout": responses, "stdout_lines": list(to_lines(responses)),} {"stdout": responses, "stdout_lines": list(to_lines(responses)), }
) )
module.exit_json(**result) module.exit_json(**result)

Loading…
Cancel
Save