From 9512d8a4173fc1d2b6395937e7b023ca1966e037 Mon Sep 17 00:00:00 2001 From: BlackAngelTV Date: Wed, 11 Nov 2026 21:39:51 +0100 Subject: [PATCH] fix(build): generate the config for builtin option parsers auto_reload_config is parsed with the builtin float, which the generator rejected because it only accepted Python functions, so regenerating the option types after any change to the defaults was impossible. --- kitty/conf/generate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kitty/conf/generate.py b/kitty/conf/generate.py index 9b97aea..419c89c 100644 --- a/kitty/conf/generate.py +++ b/kitty/conf/generate.py @@ -86,7 +86,7 @@ def generate_class(defn: Definition, loc: str) -> tuple[str, str]: if isinstance(option, MultiOption): mval: dict[str, dict[str, Any]] = {'macos': {}, 'linux': {}, '': {}} func, typ = option_type_data(option) - assert isinstance(func, types.FunctionType) + assert callable(func), getattr(func, '__name__', func) for val in option: if val.add_to_default: gr = mval[val.only] @@ -115,7 +115,7 @@ def generate_class(defn: Definition, loc: str) -> tuple[str, str]: func = str elif defn.has_color_table and option.is_color_table_color: func, typ = option_type_data(option) - assert isinstance(func, types.FunctionType) + assert callable(func), getattr(func, '__name__', func) t(f' ans[{option.name!r}] = {func.__name__}(val)') tc_imports.add((func.__module__, func.__name__)) cnum = int(option.name[5:]) @@ -130,7 +130,7 @@ def generate_class(defn: Definition, loc: str) -> tuple[str, str]: params = dict(inspect.signature(func).parameters) except Exception: params = {} - assert isinstance(func, types.FunctionType) + assert callable(func), getattr(func, '__name__', func) if 'dict_with_parse_results' in params: t(f' {func.__name__}(val, ans)') else: @@ -188,7 +188,7 @@ def generate_class(defn: Definition, loc: str) -> tuple[str, str]: for aname, action in defn.actions.items(): option_names.add(aname) action_parsers[aname] = func = action.parser_func - assert isinstance(func, types.FunctionType) + assert callable(func), getattr(func, '__name__', func) th = get_type_hints(func) rettype = th['return'] typ = option_type_as_str(rettype)