From ad2ecb58835e07294cf098d9b5d5216dfc0fde56 Mon Sep 17 00:00:00 2001 From: Derrick Chambers Date: Fri, 8 Nov 2024 06:55:18 -0800 Subject: [PATCH] fix PatchType and SpoolType type var (#458) --- dascore/utils/patch.py | 11 ++++++++--- scripts/_render_api.py | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dascore/utils/patch.py b/dascore/utils/patch.py index e10a5b43..59b6173c 100644 --- a/dascore/utils/patch.py +++ b/dascore/utils/patch.py @@ -234,9 +234,14 @@ def patch_function( Notes ----- - The original function can still be accessed with the raw_function - attribute. This may be useful for avoiding calling the patch_func - machinery multiple times from within another patch function. + - The original function can still be accessed with the raw_function + attribute. This may be useful for avoiding calling the patch_func + machinery multiple times from within another patch function. + + - If using `PatchType` or `SpoolType` type variables from the + [constants module](`dascore.constants`), make sure dascore is imported + as dc at the top of the file where the patch function is defined so + the forward refs can be resolved properly for type checking. """ def _wrapper(func): diff --git a/scripts/_render_api.py b/scripts/_render_api.py index 9617606f..20299e19 100644 --- a/scripts/_render_api.py +++ b/scripts/_render_api.py @@ -93,6 +93,9 @@ def unpact_annotation(obj, data_dict, address_dict) -> str: # just assume the bound string is resolvable key = str(obj).split("('")[-1].replace("')", "") name = key.split(".")[-1] + # dc. is the same as dascore. + if key.startswith("dc."): + key = f"dascore.{key[3:]}" return f"[{name}](`{key}`)" # Array-like thing from numpy #TODO improve this elif "numpy.typing" in str_rep: