From 6b2b523fba64729c57d9a8497cbee58ee82d204c Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 22 Feb 2021 14:03:44 +0800 Subject: [PATCH] mgr/influx: avoid casting variable self.config is a dict with elements of different types, to appease mypy, we would need to cast the indexed item to the expected type. another way is to use f-string, so the variable are always printed using `__str__`. Signed-off-by: Kefu Chai --- src/pybind/mgr/influx/module.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index c58d2d547d8..4d2c46c343c 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -122,15 +122,14 @@ class Module(MgrModule): self.log.debug('Writing points %d to Influx took %.3f seconds', len(points), runtime) except RequestException as e: - self.log.exception("Failed to connect to Influx host %s:%d", - self.config['hostname'], self.config['port']) + hostname = self.config['hostname'] + port = self.config['port'] + self.log.exception(f"Failed to connect to Influx host {hostname}:{port}") self.health_checks.update({ 'MGR_INFLUX_SEND_FAILED': { 'severity': 'warning', 'summary': 'Failed to send data to InfluxDB server ' - 'at %s:%d due to an connection error' - % (self.config['hostname'], - self.config['port']), + f'at {hostname}:{port} due to an connection error', 'detail': [str(e)] } }) -- 2.39.5