Module: check_mk
Branch: master
Commit: 029c7d9a20c271a3e010107704c5e336189862c0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=029c7d9a20c271…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 20 17:49:54 2018 +0100
Re-enable pylint for omd; Fix unidiomatic-typecheck
Change-Id: If053969122e2460ea5bea02f8384a071a56a80fb
---
omd/packages/omd/omdlib/main.py | 6 +++---
tests/pylint/test_pylint.py | 11 ++++++++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/omd/packages/omd/omdlib/main.py b/omd/packages/omd/omdlib/main.py
index 6fc5f1f..b4e1726 100644
--- a/omd/packages/omd/omdlib/main.py
+++ b/omd/packages/omd/omdlib/main.py
@@ -2018,7 +2018,7 @@ def validate_config_change_commands(config_hooks, settings):
# Check if value is valid. Choices are either a list of allowed
# keys or a regular expression
- if type(hook["choices"]) == list:
+ if isinstance(hook["choices"], list):
choices = [var for (var, _descr) in hook["choices"]]
if value not in choices:
bail_out("Invalid value %r for %r. Allowed are: %s\n" % \
@@ -2048,7 +2048,7 @@ def config_set(site, config_hooks, args):
# Check if value is valid. Choices are either a list of allowed
# keys or a regular expression
- if type(hook["choices"]) == list:
+ if isinstance(hook["choices"], list):
choices = [var for (var, _descr) in hook["choices"]]
if value not in choices:
sys.stderr.write("Invalid value for '%s'. Allowed are:
%s\n" % \
@@ -2199,7 +2199,7 @@ def config_configure_hook(site, config_hooks, hook_name):
descr = hook["description"].replace("\n\n",
"\001").replace("\n", " ").replace("\001",
"\n\n")
value = site.conf[hook_name]
choices = hook["choices"]
- if type(choices) == list:
+ if isinstance(choices, list):
dialog_function = dialog_menu
else:
dialog_function = dialog_regex
diff --git a/tests/pylint/test_pylint.py b/tests/pylint/test_pylint.py
index 078ddff..a09747e 100755
--- a/tests/pylint/test_pylint.py
+++ b/tests/pylint/test_pylint.py
@@ -10,6 +10,7 @@ import shutil
from testlib import cmk_path, cmc_path, cme_path, repo_path
import testlib.pylint_cmk as pylint_cmk
+
@pytest.fixture(scope="function")
def pylint_test_dir():
base_path = os.environ.get("WORKDIR")
@@ -36,6 +37,9 @@ def pylint_test_dir():
def test_pylint(pylint_test_dir):
# Only specify the path to python packages or modules here
modules_or_packages = [
+ # OMD
+ "omd/packages/omd/omdlib",
+
# Check_MK base
"cmk_base",
# TODO: Check if this kind of "overlay" really works.
@@ -69,7 +73,7 @@ def test_pylint(pylint_test_dir):
# We use our own search logic to find scripts without python extension
search_paths = [
- "omd/packages/omd",
+ "omd/packages/omd.bin",
"bin",
"notifications",
"agents/plugins",
@@ -83,7 +87,7 @@ def test_pylint(pylint_test_dir):
for path in search_paths:
abs_path = cmk_path() + "/" + path
for fname in pylint_cmk.get_pylint_files(abs_path, "*"):
- modules_or_packages.append(path + "/" + fname)
+ modules_or_packages.append(path + "/" + fname)
exit_code = pylint_cmk.run_pylint(cmk_path(), modules_or_packages)
assert exit_code == 0, "PyLint found an error"
@@ -139,7 +143,8 @@ def inv_tree(path, default_value=None):
def _compile_bakery_plugins(pylint_test_dir):
with open(pylint_test_dir + "/cmk_bakery_plugins.py", "w") as f:
- pylint_cmk.add_file(f, os.path.realpath(os.path.join(cmc_path(),
"cmk_base/cee/agent_bakery_plugins.py")))
+ pylint_cmk.add_file(
+ f, os.path.realpath(os.path.join(cmc_path(),
"cmk_base/cee/agent_bakery_plugins.py")))
# This pylint warning is incompatible with our "concatenation
technology".
f.write("# pylint: disable=reimported\n")