From 5cf5540250fa67068e2e3c0f36d67f0fa6cbbbb4 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 27 Jan 2021 12:58:45 +0800 Subject: [PATCH] mgr/zabbix: cast port to int to appease mypy Signed-off-by: Kefu Chai --- src/pybind/mgr/zabbix/module.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/zabbix/module.py b/src/pybind/mgr/zabbix/module.py index c16b98cfb10..c4f19f38c8b 100644 --- a/src/pybind/mgr/zabbix/module.py +++ b/src/pybind/mgr/zabbix/module.py @@ -157,8 +157,11 @@ class Module(MgrModule): for server in servers: uri = re.match("(?:(?:\[?)([a-z0-9-\.]+|[a-f0-9:\.]+)(?:\]?))(?:((?::))([0-9]{1,5}))?$", server) if uri: - zabbix_host, sep, zabbix_port = uri.groups() - zabbix_port = zabbix_port if sep == ':' else self.config['zabbix_port'] + zabbix_host, sep, opt_zabbix_port = uri.groups() + if sep == ':': + zabbix_port = int(opt_zabbix_port) + else: + zabbix_port = cast(int, self.config['zabbix_port']) self._zabbix_hosts.append({'zabbix_host': zabbix_host, 'zabbix_port': zabbix_port}) else: self.log.error('Zabbix host "%s" is not valid', server) -- 2.39.5