]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr: narrow get_metadata return type with @overload
authorKefu Chai <k.chai@proxmox.com>
Tue, 5 May 2026 01:35:00 +0000 (09:35 +0800)
committerKefu Chai <k.chai@proxmox.com>
Wed, 13 May 2026 07:55:43 +0000 (15:55 +0800)
commit5722e489f8fbacb865eabca5f94221c36d7eea00
tree7bdae2116fb26c8aa123d2662376e877c798f603
parent29232f2a8de4a6184ac90e1f093ce51372a0d1db
mgr: narrow get_metadata return type with @overload

Enable type narrowing for get_metadata() when a non-None default is
provided. Previously, the return type was always `Optional[Dict[str, str]]`,
forcing callers to use defensive `assert metadata` checks even when
a result was guaranteed.

The wrapper returns either the metadata from `_ceph_get_metadata()` or the
caller-supplied default. Providing an `@overload` allows type checkers to
prove the result is non-None, avoiding invalid assertions for falsy
defaults (like an empty defaultdict).

This is a hygienic change with no runtime impact.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/pybind/mgr/mgr_module.py