mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Start linting 3rd-party imports
This commit is contained in:
parent
5de563bb77
commit
d7f05e68ee
39 changed files with 120 additions and 47 deletions
13
.pylintrc
13
.pylintrc
|
@ -25,7 +25,8 @@ load-plugins=saltpylint.pep8,
|
|||
saltpylint.py3modernize,
|
||||
saltpylint.smartup,
|
||||
saltpylint.minpyver,
|
||||
saltpylint.salttesting
|
||||
saltpylint.salttesting,
|
||||
saltpylint.thirdparty
|
||||
|
||||
# Use multiple processes to speed up Pylint.
|
||||
# Don't bump this values on PyLint 1.4.0 - Know bug that ignores the passed --rcfile
|
||||
|
@ -47,6 +48,16 @@ fileperms-ignore-paths=tests/runtests.py,tests/jenkins*.py,tests/saltsh.py,tests
|
|||
# Minimum Python Version To Enforce
|
||||
minimum-python-version = 2.7
|
||||
|
||||
# Allowed 3rd-party package imports
|
||||
allowed-3rd-party-modules = msgpack,
|
||||
tornado,
|
||||
yaml,
|
||||
jinja2,
|
||||
Crypto,
|
||||
requests,
|
||||
libcloud,
|
||||
zmq
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
||||
|
|
|
@ -22,7 +22,8 @@ load-plugins=saltpylint.pep8,
|
|||
saltpylint.py3modernize,
|
||||
saltpylint.smartup,
|
||||
saltpylint.minpyver,
|
||||
saltpylint.salttesting
|
||||
saltpylint.salttesting,
|
||||
saltpylint.thirdparty
|
||||
|
||||
# Use multiple processes to speed up Pylint.
|
||||
# Don't bump this values on PyLint 1.4.0 - Know bug that ignores the passed --rcfile
|
||||
|
@ -44,6 +45,16 @@ fileperms-ignore-paths=tests/runtests.py,tests/jenkins*.py,tests/saltsh.py,tests
|
|||
# Minimum Python Version To Enforce
|
||||
minimum-python-version = 2.7
|
||||
|
||||
# Allowed 3rd-party package imports
|
||||
allowed-3rd-party-modules = msgpack,
|
||||
tornado,
|
||||
yaml,
|
||||
jinja2,
|
||||
Crypto,
|
||||
requests,
|
||||
libcloud,
|
||||
zmq
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
||||
|
|
|
@ -130,7 +130,7 @@ def auth(username, password):
|
|||
if not is_connection_usable():
|
||||
connection.close()
|
||||
|
||||
import django.contrib.auth # pylint: disable=import-error
|
||||
import django.contrib.auth # pylint: disable=import-error,3rd-party-module-not-gated
|
||||
user = django.contrib.auth.authenticate(username=username, password=password)
|
||||
if user is not None:
|
||||
if user.is_active:
|
||||
|
|
|
@ -10,15 +10,20 @@ import time
|
|||
import logging
|
||||
|
||||
# Import Salt libs
|
||||
from raet import raeting, nacling
|
||||
from raet.lane.stacking import LaneStack
|
||||
from raet.lane.yarding import RemoteYard
|
||||
import salt.config
|
||||
import salt.client
|
||||
import salt.utils
|
||||
import salt.syspaths as syspaths
|
||||
from salt.utils import kinds
|
||||
|
||||
try:
|
||||
from raet import raeting, nacling
|
||||
from raet.lane.stacking import LaneStack
|
||||
from raet.lane.yarding import RemoteYard
|
||||
HAS_RAET_LIBS = True
|
||||
except ImportError:
|
||||
HAS_RAET_LIBS = False
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
The core behaviors used by minion and master
|
||||
'''
|
||||
# pylint: disable=W0232
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
|
|
|
@ -12,6 +12,7 @@ without the need for a swarm of real minions.
|
|||
'''
|
||||
|
||||
# pylint: disable=W0232
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
Jobber Behaviors
|
||||
'''
|
||||
# pylint: disable=W0232
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
'''
|
||||
Define the behaviors used in the maintenance process
|
||||
'''
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
from __future__ import absolute_import
|
||||
# Import python libs
|
||||
import multiprocessing
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
'''
|
||||
Start the reactor!
|
||||
'''
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
from __future__ import absolute_import
|
||||
# Import salt libs
|
||||
import salt.utils.reactor
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
The core behaviors used by minion and master
|
||||
'''
|
||||
# pylint: disable=W0232
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
IoFlo behaviors for running a ZeroMQ based master
|
||||
'''
|
||||
# pylint: disable=W0232
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
|
|
|
@ -10,7 +10,7 @@ test.run()
|
|||
|
||||
'''
|
||||
# pylint: skip-file
|
||||
# pylint: disable=C0103
|
||||
# pylint: disable=C0103,3rd-party-module-not-gated
|
||||
|
||||
import sys
|
||||
if sys.version_info < (2, 7):
|
||||
|
|
|
@ -6,6 +6,7 @@ Runs all the example FloScripts
|
|||
|
||||
|
||||
'''
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function
|
||||
|
|
|
@ -1016,7 +1016,7 @@ class RaetKey(Key):
|
|||
'''
|
||||
Use libnacl to generate and safely save a private key
|
||||
'''
|
||||
import libnacl.public
|
||||
import libnacl.dual # pylint: disable=3rd-party-module-not-gated
|
||||
d_key = libnacl.dual.DualSecret()
|
||||
keydir, keyname, _, _ = self._get_key_attrs(keydir, keyname,
|
||||
keysize, user)
|
||||
|
|
|
@ -24,7 +24,7 @@ from stat import S_IMODE
|
|||
# pylint: disable=import-error,no-name-in-module,redefined-builtin
|
||||
import salt.ext.six as six
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
import ipaddress # pylint: disable=3rd-party-module-not-gated
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt.ext.six.moves import range
|
||||
|
|
|
@ -59,13 +59,13 @@ def __virtual__():
|
|||
|
||||
|
||||
def _vartree():
|
||||
import portage
|
||||
import portage # pylint: disable=3rd-party-module-not-gated
|
||||
portage = reload(portage)
|
||||
return portage.db[portage.root]['vartree']
|
||||
|
||||
|
||||
def _porttree():
|
||||
import portage
|
||||
import portage # pylint: disable=3rd-party-module-not-gated
|
||||
portage = reload(portage)
|
||||
return portage.db[portage.root]['porttree']
|
||||
|
||||
|
|
|
@ -25,7 +25,11 @@ from __future__ import absolute_import
|
|||
import logging
|
||||
|
||||
# import third party
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
HAS_REQUESTS = False
|
||||
|
||||
# import salt
|
||||
from salt.ext import six
|
||||
|
@ -63,6 +67,8 @@ def __virtual__():
|
|||
'''
|
||||
Return the execution module virtualname.
|
||||
'''
|
||||
if HAS_REQUESTS is False:
|
||||
return False, 'The requests python package is not installed'
|
||||
return __virtualname__
|
||||
|
||||
|
||||
|
|
|
@ -59,17 +59,23 @@ from salt.modules.file import (check_hash, # pylint: disable=W0611
|
|||
from salt.utils import namespaced_function as _namespaced_function
|
||||
|
||||
HAS_WINDOWS_MODULES = False
|
||||
if salt.utils.is_windows():
|
||||
import win32api
|
||||
import win32file
|
||||
import win32con
|
||||
from pywintypes import error as pywinerror
|
||||
HAS_WINDOWS_MODULES = True
|
||||
try:
|
||||
if salt.utils.is_windows():
|
||||
import win32api
|
||||
import win32file
|
||||
import win32con
|
||||
from pywintypes import error as pywinerror
|
||||
HAS_WINDOWS_MODULES = True
|
||||
except ImportError:
|
||||
HAS_WINDOWS_MODULES = False
|
||||
|
||||
HAS_WIN_DACL = False
|
||||
if salt.utils.is_windows():
|
||||
import salt.utils.win_dacl
|
||||
HAS_WIN_DACL = salt.utils.win_dacl.HAS_WIN32
|
||||
try:
|
||||
if salt.utils.is_windows():
|
||||
import salt.utils.win_dacl
|
||||
HAS_WIN_DACL = salt.utils.win_dacl.HAS_WIN32
|
||||
except ImportError:
|
||||
HAS_WIN_DACL = False
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -34,11 +34,14 @@ import copy
|
|||
from salt.utils import namespaced_function as _namespaced_function
|
||||
|
||||
# Import 3rd Party Libs
|
||||
if salt.utils.is_windows():
|
||||
import wmi
|
||||
import salt.utils.winapi
|
||||
HAS_WMI = True
|
||||
else:
|
||||
try:
|
||||
if salt.utils.is_windows():
|
||||
import wmi
|
||||
import salt.utils.winapi
|
||||
HAS_WMI = True
|
||||
else:
|
||||
HAS_WMI = False
|
||||
except ImportError:
|
||||
HAS_WMI = False
|
||||
|
||||
__opts__ = {}
|
||||
|
|
|
@ -470,7 +470,7 @@ from multiprocessing import Process, Pipe
|
|||
|
||||
# Import third-party libs
|
||||
# pylint: disable=import-error
|
||||
import cherrypy
|
||||
import cherrypy # pylint: disable=3rd-party-module-not-gated
|
||||
import yaml
|
||||
import salt.ext.six as six
|
||||
# pylint: enable=import-error
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# encoding: utf-8
|
||||
from __future__ import absolute_import
|
||||
import cherrypy
|
||||
|
||||
from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
|
||||
from ws4py.websocket import WebSocket
|
||||
try:
|
||||
import cherrypy
|
||||
|
||||
from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
|
||||
from ws4py.websocket import WebSocket
|
||||
except ImportError:
|
||||
raise
|
||||
|
||||
cherrypy.tools.websocket = WebSocketTool()
|
||||
WebSocketPlugin(cherrypy.engine).subscribe()
|
||||
|
|
|
@ -48,7 +48,7 @@ from __future__ import absolute_import
|
|||
|
||||
import os
|
||||
|
||||
import cherrypy
|
||||
import cherrypy # pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
|
||||
def bootstrap_app():
|
||||
|
|
|
@ -97,8 +97,10 @@ def ext_pillar(minion_id, pillar, **kwargs):
|
|||
|
||||
# If reclass is installed, __virtual__ put it onto the search path, so we
|
||||
# don't need to protect against ImportError:
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
from reclass.adapters.salt import ext_pillar as reclass_ext_pillar
|
||||
from reclass.errors import ReclassException
|
||||
# pylint: enable=3rd-party-module-not-gated
|
||||
|
||||
try:
|
||||
# the source path we used above isn't something reclass needs to care
|
||||
|
|
|
@ -15,9 +15,13 @@ This renderer requires `Dogeon`__ (installable via pip)
|
|||
from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
import dson
|
||||
import logging
|
||||
|
||||
try:
|
||||
import dson
|
||||
except ImportError:
|
||||
raise
|
||||
|
||||
# Import salt libs
|
||||
from salt.ext import six
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ def __virtual__():
|
|||
'''
|
||||
min_version = '1.3.1'
|
||||
if HAS_LIBS:
|
||||
import sleekxmpp
|
||||
import sleekxmpp # pylint: disable=3rd-party-module-not-gated
|
||||
# Certain XMPP functionaility we're using doesn't work with versions under 1.3.1
|
||||
sleekxmpp_version = distutils.version.LooseVersion(sleekxmpp.__version__)
|
||||
valid_version = distutils.version.LooseVersion(min_version)
|
||||
|
|
|
@ -85,8 +85,10 @@ def top(**kwargs):
|
|||
|
||||
# If reclass is installed, __virtual__ put it onto the search path, so we
|
||||
# don't need to protect against ImportError:
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
from reclass.adapters.salt import top as reclass_top
|
||||
from reclass.errors import ReclassException
|
||||
# pylint: enable=3rd-party-module-not-gated
|
||||
|
||||
try:
|
||||
# Salt's top interface is inconsistent with ext_pillar (see #5786) and
|
||||
|
|
|
@ -9,7 +9,7 @@ import urlparse
|
|||
# pylint: disable=import-error,no-name-in-module
|
||||
from salt.ext.six.moves.urllib.parse import urlparse
|
||||
# pylint: enable=import-error,no-name-in-module
|
||||
from mako.lookup import TemplateCollection, TemplateLookup # pylint: disable=import-error
|
||||
from mako.lookup import TemplateCollection, TemplateLookup # pylint: disable=import-error,3rd-party-module-not-gated
|
||||
|
||||
# Import salt libs
|
||||
import salt.fileclient
|
||||
|
|
|
@ -27,11 +27,11 @@ import subprocess
|
|||
|
||||
mswindows = (sys.platform == "win32")
|
||||
|
||||
if mswindows:
|
||||
try:
|
||||
from win32file import ReadFile, WriteFile
|
||||
from win32pipe import PeekNamedPipe
|
||||
import msvcrt
|
||||
else:
|
||||
except ImportError:
|
||||
import fcntl
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
import pyrax
|
||||
|
||||
try:
|
||||
import pyrax
|
||||
except ImportError:
|
||||
raise
|
||||
|
||||
|
||||
class Authenticate(object):
|
||||
|
|
|
@ -7,8 +7,11 @@ import logging
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
# Import pyrax (SDK for Rackspace cloud) third party libs
|
||||
import pyrax
|
||||
import pyrax.exceptions
|
||||
try:
|
||||
import pyrax
|
||||
import pyrax.exceptions
|
||||
except ImportError:
|
||||
raise
|
||||
|
||||
# Import salt classes
|
||||
from salt.utils.openstack.pyrax import authenticate
|
||||
|
|
|
@ -2633,7 +2633,7 @@ class SaltCallOptionParser(six.with_metaclass(OptionParserMeta,
|
|||
raise ValueError(emsg)
|
||||
|
||||
if kind == kinds.APPL_KIND_NAMES[kinds.applKinds.minion]: # minion check
|
||||
from raet.lane.yarding import Yard
|
||||
from raet.lane.yarding import Yard # pylint: disable=3rd-party-module-not-gated
|
||||
ha, dirpath = Yard.computeHa(dirpath, lanename, yardname) # pylint: disable=invalid-name
|
||||
if (os.path.exists(ha) and
|
||||
not os.path.isfile(ha) and
|
||||
|
|
|
@ -17,7 +17,7 @@ from __future__ import absolute_import
|
|||
import salt.ext.six as six
|
||||
|
||||
# No exception handling, as we want ImportError if psutil doesn't exist
|
||||
import psutil
|
||||
import psutil # pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
if psutil.version_info >= (2, 0):
|
||||
from psutil import * # pylint: disable=wildcard-import,unused-wildcard-import
|
||||
|
|
|
@ -4,6 +4,7 @@ Manage events
|
|||
|
||||
This module is used to manage events via RAET
|
||||
'''
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
|
|
|
@ -48,6 +48,7 @@ msg = raetlane.wait(share=track, timeout=5.0)
|
|||
if not msg:
|
||||
raise ValueError("Timed out out waiting for response")
|
||||
'''
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import time
|
||||
|
|
|
@ -464,6 +464,7 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
|||
return output
|
||||
|
||||
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
def render_mako_tmpl(tmplstr, context, tmplpath=None):
|
||||
import mako.exceptions
|
||||
from mako.template import Template
|
||||
|
@ -534,6 +535,7 @@ def render_cheetah_tmpl(tmplstr, context, tmplpath=None):
|
|||
'''
|
||||
from Cheetah.Template import Template
|
||||
return str(Template(tmplstr, searchList=[context]))
|
||||
# pylint: enable=3rd-party-module-not-gated
|
||||
|
||||
|
||||
def py(sfn, string=False, **kwargs): # pylint: disable=C0103
|
||||
|
|
|
@ -16,9 +16,9 @@ import socket
|
|||
import logging
|
||||
|
||||
# Import third party libs
|
||||
if sys.platform.startswith('win'):
|
||||
try:
|
||||
import win32file
|
||||
else:
|
||||
except ImportError:
|
||||
import resource
|
||||
|
||||
# Import salt libs
|
||||
|
|
|
@ -32,7 +32,7 @@ import logging
|
|||
|
||||
mswindows = (sys.platform == "win32")
|
||||
|
||||
if mswindows:
|
||||
try:
|
||||
# pylint: disable=F0401,W0611
|
||||
from win32file import ReadFile, WriteFile
|
||||
from win32pipe import PeekNamedPipe
|
||||
|
@ -41,7 +41,7 @@ if mswindows:
|
|||
import win32con
|
||||
import win32process
|
||||
# pylint: enable=F0401,W0611
|
||||
else:
|
||||
except ImportError:
|
||||
import pty
|
||||
import fcntl
|
||||
import struct
|
||||
|
|
|
@ -56,7 +56,7 @@ def service(instantiated=True):
|
|||
self.stop_event = win32event.CreateEvent(None, 0, 0, None)
|
||||
|
||||
def log(self, msg):
|
||||
import servicemanager
|
||||
import servicemanager # pylint: disable=3rd-party-module-not-gated
|
||||
servicemanager.LogInfoMsg(str(msg))
|
||||
|
||||
def sleep(self, sec):
|
||||
|
|
|
@ -644,7 +644,7 @@ def system_information():
|
|||
version = system_version()
|
||||
release = platform.release()
|
||||
if platform.win32_ver()[0]:
|
||||
import win32api
|
||||
import win32api # pylint: disable=3rd-party-module-not-gated
|
||||
if ((sys.version_info.major == 2 and sys.version_info >= (2, 7, 12)) or
|
||||
(sys.version_info.major == 3 and sys.version_info >= (3, 5, 2))):
|
||||
if win32api.GetVersionEx(1)[8] > 1:
|
||||
|
|
Loading…
Add table
Reference in a new issue