From 61bef6d5f525ec2e2b301038798dd99a15f0f7bb Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 11 Mar 2026 10:53:14 -0400 Subject: [PATCH] Strip `None` values from symcache dict before TOML write (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code Note that (again) this patch was orig by @dnks and broken out from a larger commit which added unnecessary/out-of-scope changes we didn't end up requiring. --- piker/data/_symcache.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/piker/data/_symcache.py b/piker/data/_symcache.py index 1f1cb9ec..cfcf6ce6 100644 --- a/piker/data/_symcache.py +++ b/piker/data/_symcache.py @@ -105,6 +105,15 @@ class SymbologyCache(Struct): def write_config(self) -> None: + def clean_dict_for_toml(d): + '''Remove None values from dict recursively for TOML serialization''' + if isinstance(d, dict): + return {k: clean_dict_for_toml(v) for k, v in d.items() if v is not None} + elif isinstance(d, list): + return [clean_dict_for_toml(item) for item in d if item is not None] + else: + return d + # put the backend's pair-struct type ref at the top # of file if possible. cachedict: dict[str, Any] = { @@ -125,7 +134,9 @@ class SymbologyCache(Struct): dct = cachedict[key] = {} for key, struct in table.items(): - dct[key] = struct.to_dict(include_non_members=False) + raw_dict = struct.to_dict(include_non_members=False) + # Clean None values for TOML compatibility + dct[key] = clean_dict_for_toml(raw_dict) try: with self.fp.open(mode='wb') as fp: