Module: check_mk
Branch: master
Commit: 7dfb9419c80f7476a3750b42fd81f518c1410ab0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7dfb9419c80f74…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Apr 17 08:26:21 2019 +0200
Increase mypy scope a in cmk_base code
Change-Id: I4e3c37ae38cd272fcbb8234d85339a8efc770e29
---
cmk_base/data_sources/__init__.py | 2 +-
cmk_base/snmp_utils.py | 8 +++++++-
mypy.ini | 18 ++++++++++++++++++
tests/static/Makefile | 4 ++++
4 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/cmk_base/data_sources/__init__.py b/cmk_base/data_sources/__init__.py
index 8c79bcc..cb01972 100644
--- a/cmk_base/data_sources/__init__.py
+++ b/cmk_base/data_sources/__init__.py
@@ -65,7 +65,7 @@ from .host_sections import HostSections, MultiHostSections
try:
import cmk_base.cee.keepalive as keepalive
except Exception:
- keepalive = None
+ keepalive = None # type: ignore
def _in_keepalive_mode():
diff --git a/cmk_base/snmp_utils.py b/cmk_base/snmp_utils.py
index cf33c06..5f09087 100644
--- a/cmk_base/snmp_utils.py
+++ b/cmk_base/snmp_utils.py
@@ -74,7 +74,13 @@ def is_snmpv3_host(host_config):
# And if it is a six-tuple, it has the following additional arguments:
# (5) privacy protocol (DES|AES) (-x)
# (6) privacy protocol pass phrase (-X)
-SNMPCredentials = Union[str, Tuple[str, str, str, str], Tuple[str, str, str, str],
Tuple[str, str]]
+SNMPCommunity = str
+# TODO: This does not work as intended
+#SNMPv3NoAuthNoPriv = Tuple[str, str]
+#SNMPv3AuthNoPriv = Tuple[str, str, str, str]
+#SNMPv3AuthPriv = Tuple[str, str, str, str, str, str]
+#SNMPCredentials = Union[SNMPCommunity, SNMPv3NoAuthNoPriv, SNMPv3AuthNoPriv,
SNMPv3AuthPriv]
+SNMPCredentials = Union[SNMPCommunity, Tuple[str, ...]]
# Wraps the configuration of a host into a single object for the SNMP code
SNMPHostConfig = NamedTuple(
diff --git a/mypy.ini b/mypy.ini
index cf6ac2b..b910d61 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -2,3 +2,21 @@
python_version = 2.7
strict_optional = True
follow_imports = silent
+
+# Used by cmk_base/data_sources/impi.py - not able to make this visible easily
+# Disabling checking this external module for the moment to be able to enable
+# checking our code.
+[mypy-pyghmi.*]
+ignore_missing_imports = True
+
+# Used by cmk_base/data_sources/tcp.py. Same as above.
+[mypy-Cryptodome.*]
+ignore_missing_imports = True
+
+# Used by cmk_base/cee/rrd.py. Same as above
+[mypy-rrdtool.*]
+ignore_missing_imports = True
+
+# Used by cmk_base/cee/inline_snmp.py. Same as above
+[mypy-netsnmp.*]
+ignore_missing_imports = True
diff --git a/tests/static/Makefile b/tests/static/Makefile
index 84a9807..632f546 100644
--- a/tests/static/Makefile
+++ b/tests/static/Makefile
@@ -6,6 +6,10 @@ FILES_TO_CHECK := $(realpath $(addprefix ../../cmk/ec/,defaults.py
export.py mai
$(realpath $(wildcard ../../cmk/notification_plugins/*.py)) \
$(realpath $(wildcard ../../cmk/special_agents/*.py)) \
$(realpath $(wildcard ../../cmk_base/*.py)) \
+ $(wildcard $(realpath ../..)/cmk_base/cee/*.py) \
+ $(wildcard $(realpath ../..)/cmk_base/automations/*.py) \
+ $(wildcard $(realpath ../..)/cmk_base/modes/*.py) \
+ $(wildcard $(realpath ../..)/cmk_base/data_sources/*.py) \
$(realpath $(addprefix ../../cmk/gui/,dashboard.py exceptions.py globals.py
htmllib.py \
i18n.py sidebar.py sites.py table.py visuals.py
permissions.py)) \
$(realpath $(addprefix ../../cmk/gui/watolib/,rulespecs.py)) \