Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions polyapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshi922 feel free to dump the og comment here and update the comment to whatever it should be if you were writing this for the first time!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt have to be this deploy! just whenever is convenient

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp, missed that one! Will get it in with other Python SDK work!


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
Expand Down
6 changes: 1 addition & 5 deletions polyapi/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" }]
dependencies = [
Expand Down