diff --git a/polyapi/utils.py b/polyapi/utils.py index 6a7b475..fb57199 100644 --- a/polyapi/utils.py +++ b/polyapi/utils.py @@ -73,9 +73,23 @@ def print_red(s: str): def add_type_import_path(function_name: str, arg: str) -> str: """if not basic type, coerce to camelCase and add the import path""" - # for now, just treat Callables as basic types + # outdated og comment - for now, just treat Callables as basic types + # from now, we start qualifying non-basic types :)) + # e.g. Callable[[EmailAddress, Dict, Dict, Dict], None] + # becomes Callable[[Set_profile_email.EmailAddress, Dict, Dict, Dict], None] + if arg.startswith("Callable"): - return arg + inner = arg[len("Callable["):-1] # strip outer Callable[...] + parts = [p.strip() for p in inner.split(",")] + qualified = [] + for p in parts: + clean = p.strip("[] ") + if clean and clean not in BASIC_PYTHON_TYPES: + replacement = f"{to_func_namespace(function_name)}.{camelCase(clean)}" + p = p.replace(clean, replacement) + qualified.append(p) + return "Callable[" + ",".join(qualified) + "]" + # return arg if arg in BASIC_PYTHON_TYPES: return arg diff --git a/polyapi/webhook.py b/polyapi/webhook.py index 8d68186..75a4a16 100644 --- a/polyapi/webhook.py +++ b/polyapi/webhook.py @@ -124,11 +124,7 @@ def render_webhook_handle( ) -> Tuple[str, str]: try: function_args, function_args_def = parse_arguments(function_name, arguments) - - if "WebhookEventType" in function_args: - # let's add the function name import! - function_args = function_args.replace("WebhookEventType", f"{to_func_namespace(function_name)}.WebhookEventType") - + func_str = WEBHOOK_TEMPLATE.format( description=function_description, function_id=function_id, diff --git a/pyproject.toml b/pyproject.toml index 3517e7c..94627d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "polyapi-python" -version = "0.3.13.dev1" # bump +version = "0.3.13.dev2" # bump description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers" authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }] dependencies = [