From: John Mulligan Date: Fri, 1 Nov 2024 18:36:13 +0000 (-0400) Subject: cephadm: update some type annotations X-Git-Tag: v20.0.0~647^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1a2346e612b7d6f90bc54d4733607cc9462bf965;p=ceph.git cephadm: update some type annotations Update some function typing from the old comment based style to the current type annotations style. Not only does this modernize the code but it fixes issues found by newer versions of flake8 that were flagging types only referenced in type comments as unused imports. Part of an effort to get ceph tox environments passing on Python 3.12. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadmlib/daemons/ingress.py b/src/cephadm/cephadmlib/daemons/ingress.py index 8f4f6b08991..c88e39ac025 100644 --- a/src/cephadm/cephadmlib/daemons/ingress.py +++ b/src/cephadm/cephadmlib/daemons/ingress.py @@ -82,8 +82,7 @@ class HAproxy(ContainerDaemonForm): def get_daemon_args(self) -> List[str]: return ['haproxy', '-f', '/var/lib/haproxy/haproxy.cfg'] - def validate(self): - # type: () -> None + def validate(self) -> None: if not is_fsid(self.fsid): raise Error('not an fsid: %s' % self.fsid) if not self.daemon_id: @@ -99,12 +98,10 @@ class HAproxy(ContainerDaemonForm): 'required file missing from config-json: %s' % fname ) - def get_daemon_name(self): - # type: () -> str + def get_daemon_name(self) -> str: return '%s.%s' % (self.daemon_type, self.daemon_id) - def get_container_name(self, desc=None): - # type: (Optional[str]) -> str + def get_container_name(self, desc: Optional[str] = None) -> str: cname = 'ceph-%s-%s' % (self.fsid, self.get_daemon_name()) if desc: cname = '%s-%s' % (cname, desc) @@ -212,8 +209,7 @@ class Keepalived(ContainerDaemonForm): # populate files from the config-json populate_files(data_dir, self.files, uid, gid) - def validate(self): - # type: () -> None + def validate(self) -> None: if not is_fsid(self.fsid): raise Error('not an fsid: %s' % self.fsid) if not self.daemon_id: @@ -229,20 +225,17 @@ class Keepalived(ContainerDaemonForm): 'required file missing from config-json: %s' % fname ) - def get_daemon_name(self): - # type: () -> str + def get_daemon_name(self) -> str: return '%s.%s' % (self.daemon_type, self.daemon_id) - def get_container_name(self, desc=None): - # type: (Optional[str]) -> str + def get_container_name(self, desc: Optional[str] = None) -> str: cname = 'ceph-%s-%s' % (self.fsid, self.get_daemon_name()) if desc: cname = '%s-%s' % (cname, desc) return cname @staticmethod - def get_container_envs(): - # type: () -> List[str] + def get_container_envs() -> List[str]: envs = [ 'KEEPALIVED_AUTOCONF=false', 'KEEPALIVED_CONF=/etc/keepalived/keepalived.conf',