diff --git a/my/core/query.py b/my/core/query.py index f78a1f7..4e00569 100644 --- a/my/core/query.py +++ b/my/core/query.py @@ -52,9 +52,9 @@ def locate_function(module_name: str, function_name: str) -> Callable[[], Iterab """ try: mod = importlib.import_module(module_name) - for (fname, func) in inspect.getmembers(mod, inspect.isfunction): + for (fname, f) in inspect.getmembers(mod, inspect.isfunction): if fname == function_name: - return func + return f # in case the function is defined dynamically, # like with a globals().setdefault(...) or a module-level __getattr__ function func = getattr(mod, function_name, None) diff --git a/my/core/serialize.py b/my/core/serialize.py index 1ef7bc0..c5f4cba 100644 --- a/my/core/serialize.py +++ b/my/core/serialize.py @@ -62,10 +62,9 @@ def _dumps_factory(**kwargs) -> Callable[[Any], str]: if _additional_default is not None and callable(_additional_default): def wrapped_default(obj: Any) -> Any: + assert _additional_default is not None try: - # hmm... shouldn't mypy know that _additional_default is not None here? - # assert _additional_default is not None - return _additional_default(obj) # type: ignore[misc] + return _additional_default(obj) except TypeError: # expected TypeError, signifies couldn't be encoded by custom # serializer function. Try _default_encode from here