doc: Address pylint issues in conf.py

pylint finds issues in doc/conf.py:

```
pylint3 conf.py
************* Module conf
conf.py:226:0: C0330: Wrong hanging indentation (remove 4 spaces).
        os.pardir,  # salt itself (for autodoc)
    |   ^ (bad-continuation)
conf.py:227:0: C0330: Wrong hanging indentation (remove 4 spaces).
        '_ext',  # custom Sphinx extensions
    |   ^ (bad-continuation)
conf.py:374:0: C0301: Line too long (106/100) (line-too-long)
conf.py:442:0: C0330: Wrong hanging indentation (add 2 spaces).
  ('contents', 'Salt.tex', 'Salt Documentation', 'SaltStack, Inc.', 'manual'),
  ^ | (bad-continuation)
conf.py:485:0: C0301: Line too long (107/100) (line-too-long)
conf.py:27:0: W0613: Unused argument 'args' (unused-argument)
conf.py:27:0: W0613: Unused argument 'kwargs' (unused-argument)
conf.py:58:4: R0201: Method could be a function (no-self-use)
conf.py:198:8: R1705: Unnecessary "else" after "return" (no-else-return)
conf.py:197:0: W0613: Unused argument 'iargs' (unused-argument)
conf.py:197:0: W0613: Unused argument 'ikwargs' (unused-argument)
conf.py:187:0: W0613: Unused argument 'oargs' (unused-argument)
conf.py:187:0: W0613: Unused argument 'okwargs' (unused-argument)
conf.py:533:0: R0913: Too many arguments (6/5) (too-many-arguments)
conf.py:533:25: W0613: Unused argument 'app' (unused-argument)
conf.py:533:30: W0613: Unused argument 'what' (unused-argument)
conf.py:533:47: W0613: Unused argument 'skip' (unused-argument)
conf.py:533:53: W0613: Unused argument 'options' (unused-argument)
conf.py:542:7: W0621: Redefining name 'path' from outer scope (line 230) (redefined-outer-name)
conf.py:6:0: W0611: Unused import functools (unused-import)
conf.py:310:4: W0611: Unused import sphinxcontrib.spelling (unused-import)
```

Address those or silince pylint for wanted behavior.

Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
This commit is contained in:
Benjamin Drung 2018-12-19 12:24:45 +01:00
parent 67a3e371a6
commit 08ef6694ea

View file

@ -3,7 +3,6 @@
'''
Sphinx documentation for Salt
'''
import functools
import sys
import os
import types
@ -12,7 +11,6 @@ import time
from sphinx.directives import TocTree
# pylint: disable=R0903
class Mock(object):
'''
Mock out specified imports.
@ -24,7 +22,7 @@ class Mock(object):
http://read-the-docs.readthedocs.org/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules
'''
def __init__(self, mapping=None, *args, **kwargs):
def __init__(self, mapping=None, *args, **kwargs): # pylint: disable=unused-argument
"""
Mapping allows autodoc to bypass the Mock object, but actually assign
a specific value, expected by a specific attribute returned.
@ -40,8 +38,6 @@ class Mock(object):
return Mock(mapping=self.__mapping)
def __getattr__(self, name):
#__mapping = {'total': 0}
data = None
if name in self.__mapping:
data = self.__mapping.get(name)
elif name in ('__file__', '__path__'):
@ -55,13 +51,13 @@ class Mock(object):
def __iter__(self):
return self
def __next__(self):
@staticmethod
def __next__():
raise StopIteration
# For Python 2
next = __next__
# pylint: enable=R0903
MOCK_MODULES = [
# Python stdlib
@ -187,7 +183,8 @@ for mod_name in MOCK_MODULES:
mock = Mock()
sys.modules[mod_name] = mock
def mock_decorator_with_params(*oargs, **okwargs):
def mock_decorator_with_params(*oargs, **okwargs): # pylint: disable=unused-argument
'''
Optionally mock a decorator that takes parameters
@ -197,13 +194,13 @@ def mock_decorator_with_params(*oargs, **okwargs):
def things():
pass
'''
def inner(fn, *iargs, **ikwargs):
def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument
if hasattr(fn, '__call__'):
return fn
else:
return Mock()
return Mock()
return inner
# Define a fake version attribute for the following libs.
sys.modules['libcloud'].__version__ = '0.0.0'
sys.modules['msgpack'].version = (1, 0, 0)
@ -211,8 +208,6 @@ sys.modules['psutil'].version_info = (3, 0, 0)
sys.modules['pymongo'].version = '0.0.0'
sys.modules['ntsecuritycon'].STANDARD_RIGHTS_REQUIRED = 0
sys.modules['ntsecuritycon'].SYNCHRONIZE = 0
# Define a fake version attribute for the following libs.
sys.modules['cherrypy'].config = mock_decorator_with_params
sys.modules['tornado'].version_info = (0, 0, 0)
@ -226,12 +221,12 @@ except NameError:
docs_basepath = os.path.abspath(os.path.dirname('.'))
addtl_paths = (
os.pardir, # salt itself (for autodoc)
'_ext', # custom Sphinx extensions
os.pardir, # salt itself (for autodoc)
'_ext', # custom Sphinx extensions
)
for path in addtl_paths:
sys.path.insert(0, os.path.abspath(os.path.join(docs_basepath, path)))
for addtl_path in addtl_paths:
sys.path.insert(0, os.path.abspath(os.path.join(docs_basepath, addtl_path)))
# We're now able to import salt
@ -310,7 +305,7 @@ extensions = [
]
try:
import sphinxcontrib.spelling
import sphinxcontrib.spelling # false positive, pylint: disable=unused-import
except ImportError:
pass
else:
@ -374,7 +369,8 @@ gettext_compact = False
### HTML options
html_theme = os.environ.get('HTML_THEME', 'saltstack2') # set 'HTML_THEME=saltstack' to use previous theme
# set 'HTML_THEME=saltstack' to use previous theme
html_theme = os.environ.get('HTML_THEME', 'saltstack2')
html_theme_path = ['_themes']
html_title = u''
html_short_title = 'Salt'
@ -442,7 +438,7 @@ html_show_copyright = True
### Latex options
latex_documents = [
('contents', 'Salt.tex', 'Salt Documentation', 'SaltStack, Inc.', 'manual'),
('contents', 'Salt.tex', 'Salt Documentation', 'SaltStack, Inc.', 'manual'),
]
latex_logo = '_static/salt-logo.png'
@ -462,35 +458,36 @@ latex_elements = {
### Linkcheck options
linkcheck_ignore = [r'http://127.0.0.1',
r'http://salt:\d+',
r'http://local:\d+',
r'https://console.aws.amazon.com',
r'http://192.168.33.10',
r'http://domain:\d+',
r'http://123.456.789.012:\d+',
r'http://localhost',
r'https://groups.google.com/forum/#!forum/salt-users',
r'http://logstash.net/docs/latest/inputs/udp',
r'http://logstash.net/docs/latest/inputs/zeromq',
r'http://www.youtube.com/saltstack',
r'https://raven.readthedocs.io',
r'https://getsentry.com',
r'https://salt-cloud.readthedocs.io',
r'https://salt.readthedocs.io',
r'http://www.pip-installer.org/',
r'http://www.windowsazure.com/',
r'https://github.com/watching',
r'dash-feed://',
r'https://github.com/saltstack/salt/',
r'http://bootstrap.saltstack.org',
r'https://bootstrap.saltstack.com',
r'https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh',
r'media.readthedocs.org/dash/salt/latest/salt.xml',
r'https://portal.aws.amazon.com/gp/aws/securityCredentials',
r'https://help.github.com/articles/fork-a-repo',
r'dash-feed://https%3A//media.readthedocs.org/dash/salt/latest/salt.xml'
]
linkcheck_ignore = [
r'http://127.0.0.1',
r'http://salt:\d+',
r'http://local:\d+',
r'https://console.aws.amazon.com',
r'http://192.168.33.10',
r'http://domain:\d+',
r'http://123.456.789.012:\d+',
r'http://localhost',
r'https://groups.google.com/forum/#!forum/salt-users',
r'http://logstash.net/docs/latest/inputs/udp',
r'http://logstash.net/docs/latest/inputs/zeromq',
r'http://www.youtube.com/saltstack',
r'https://raven.readthedocs.io',
r'https://getsentry.com',
r'https://salt-cloud.readthedocs.io',
r'https://salt.readthedocs.io',
r'http://www.pip-installer.org/',
r'http://www.windowsazure.com/',
r'https://github.com/watching',
r'dash-feed://',
r'https://github.com/saltstack/salt/',
r'http://bootstrap.saltstack.org',
r'https://bootstrap.saltstack.com',
r'https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh',
r'media.readthedocs.org/dash/salt/latest/salt.xml',
r'https://portal.aws.amazon.com/gp/aws/securityCredentials',
r'https://help.github.com/articles/fork-a-repo',
r'dash-feed://https%3A//media.readthedocs.org/dash/salt/latest/salt.xml',
]
linkcheck_anchors = False
@ -534,6 +531,7 @@ epub_tocdup = False
def skip_mod_init_member(app, what, name, obj, skip, options):
# pylint: disable=too-many-arguments,unused-argument
if name.startswith('_'):
return True
if isinstance(obj, types.FunctionType) and obj.__name__ == 'mod_init':