Module: check_mk
Branch: master
Commit: 428b82daf44cc87c63e9befb45851be4f4e877a8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=428b82daf44cc8…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 16 17:25:39 2019 +0200
Spread some more type hints
Change-Id: I0de62bd4554f11617eb42be4cb8f92ca6dc310ba
---
cmk_base/default_config/base.py | 4 +++-
cmk_base/ip_lookup.py | 7 ++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/cmk_base/default_config/base.py b/cmk_base/default_config/base.py
index bb7ae96..3658a4c 100644
--- a/cmk_base/default_config/base.py
+++ b/cmk_base/default_config/base.py
@@ -24,6 +24,8 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+import typing as _typing
+
# This file contains the defaults settings for almost all configuration
# variables that can be overridden in main.mk. Some configuration
# variables are preset in checks/* as well.
@@ -54,7 +56,7 @@ piggyback_max_cachefile_age = 3600 # secs
piggyback_translation = [] # Ruleset for translating piggyback host names
service_description_translation = [] # Ruleset for translating service descriptions
simulation_mode = False
-fake_dns = False
+fake_dns = None # type: _typing.Optional[str]
agent_simulator = False
perfdata_format = "pnp" # also possible: "standard"
check_mk_perfdata_with_times = True
diff --git a/cmk_base/ip_lookup.py b/cmk_base/ip_lookup.py
index f90aede..e0580f8 100644
--- a/cmk_base/ip_lookup.py
+++ b/cmk_base/ip_lookup.py
@@ -27,6 +27,7 @@
import socket
import errno
import os
+from typing import Optional # pylint: disable=unused-import
import cmk.utils.paths
import cmk.utils.debug
@@ -37,7 +38,7 @@ import cmk_base.console as console
import cmk_base.config as config
from cmk_base.exceptions import MKIPAddressLookupError
-_fake_dns = False
+_fake_dns = None # type: Optional[str]
_enforce_localhost = False
@@ -52,10 +53,12 @@ def enforce_localhost():
def lookup_ipv4_address(hostname):
+ # type: (str) -> Optional[str]
return lookup_ip_address(hostname, 4)
def lookup_ipv6_address(hostname):
+ # type: (str) -> Optional[str]
return lookup_ip_address(hostname, 6)
@@ -66,6 +69,7 @@ def lookup_ipv6_address(hostname):
# returns None instead of raising an exception.
# FIXME: This different handling is bad. Clean this up!
def lookup_ip_address(hostname, family=None):
+ # type: (str, Optional[int]) -> Optional[str]
# Quick hack, where all IP addresses are faked (--fake-dns)
if _fake_dns:
return _fake_dns
@@ -105,6 +109,7 @@ def lookup_ip_address(hostname, family=None):
# Variables needed during the renaming of hosts (see automation.py)
def cached_dns_lookup(hostname, family):
+ # type: (str, int) -> Optional[str]
cache = cmk_base.config_cache.get_dict("cached_dns_lookup")
cache_id = hostname, family