From: Kefu Chai Date: Mon, 22 Feb 2021 06:03:44 +0000 (+0800) Subject: mgr/influx: avoid casting variable X-Git-Tag: v17.1.0~2830^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b2b523fba64729c57d9a8497cbee58ee82d204c;p=ceph.git 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 --- diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index c58d2d547d83..4d2c46c343c7 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)] } })