polyapi-python 0.3.16__py3-none-any.whl → 0.3.17.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
polyapi/generate.py CHANGED
@@ -16,7 +16,7 @@ from .webhook import render_webhook_handle
16
16
  from .typedefs import PropertySpecification, SchemaSpecDto, SpecificationDto, VariableSpecDto, TableSpecDto
17
17
  from .api import render_api_function
18
18
  from .server import render_server_function
19
- from .utils import add_import_to_init, get_auth_headers, init_the_init, print_green, to_func_namespace
19
+ from .utils import add_import_to_init, get_auth_headers, init_the_init, print_green, to_func_namespace, to_type_module_alias
20
20
  from .variables import generate_variables
21
21
  from .poly_tables import generate_tables
22
22
  from . import http_client
@@ -506,8 +506,10 @@ def add_function_file(
506
506
  with open(init_path, "r", encoding='utf-8') as f:
507
507
  init_content = f.read()
508
508
 
509
- # Prepare new content to append to __init__.py
510
- new_init_content = init_content + f"\n\nfrom . import {func_namespace}\n\n{func_str}"
509
+ # Import the generated type module under a private alias so PascalCase function
510
+ # names do not shadow their own module symbol in __init__.py.
511
+ type_module_alias = to_type_module_alias(function_name)
512
+ new_init_content = init_content + f"\n\nfrom . import {func_namespace} as {type_module_alias}\n\n{func_str}"
511
513
 
512
514
  # Use temporary files for atomic writes
513
515
  # Write to __init__.py atomically
polyapi/utils.py CHANGED
@@ -71,11 +71,17 @@ def print_red(s: str):
71
71
  print(Fore.RED + s + Style.RESET_ALL)
72
72
 
73
73
 
74
+ def to_type_module_alias(function_name: str) -> str:
75
+ """Return the internal alias used for a function's generated type module."""
76
+ return f"_{to_func_namespace(function_name)}_types"
77
+
78
+
74
79
  def add_type_import_path(function_name: str, arg: str) -> str:
75
80
  """if not basic type, coerce to camelCase and add the import path"""
76
81
  # from now, we start qualifying non-basic types :))
77
82
  # e.g. Callable[[EmailAddress, Dict, Dict, Dict], None]
78
83
  # becomes Callable[[Set_profile_email.EmailAddress, Dict, Dict, Dict], None]
84
+ type_module_alias = to_type_module_alias(function_name)
79
85
 
80
86
  if arg.startswith("Callable"):
81
87
  inner = arg[len("Callable["):-1] # strip outer Callable[...]
@@ -84,7 +90,7 @@ def add_type_import_path(function_name: str, arg: str) -> str:
84
90
  for p in parts:
85
91
  clean = p.strip("[] ")
86
92
  if clean and clean not in BASIC_PYTHON_TYPES:
87
- replacement = f"{to_func_namespace(function_name)}.{camelCase(clean)}"
93
+ replacement = f"{type_module_alias}.{camelCase(clean)}"
88
94
  p = p.replace(clean, replacement)
89
95
  qualified.append(p)
90
96
  return "Callable[" + ",".join(qualified) + "]"
@@ -100,11 +106,11 @@ def add_type_import_path(function_name: str, arg: str) -> str:
100
106
  else:
101
107
  if '"' in sub:
102
108
  sub = sub.replace('"', "")
103
- return f'List["{to_func_namespace(function_name)}.{camelCase(sub)}"]'
109
+ return f'List["{type_module_alias}.{camelCase(sub)}"]'
104
110
  else:
105
- return f"List[{to_func_namespace(function_name)}.{camelCase(sub)}]"
111
+ return f"List[{type_module_alias}.{camelCase(sub)}]"
106
112
 
107
- return f"{to_func_namespace(function_name)}.{camelCase(arg)}"
113
+ return f"{type_module_alias}.{camelCase(arg)}"
108
114
 
109
115
 
110
116
  def get_type_and_def(
@@ -352,4 +358,4 @@ def return_type_already_defined_in_args(return_type_name: str, args_def: str) ->
352
358
  basic_match = bool(re.search(basic_pattern, args_def, re.MULTILINE))
353
359
  class_pattern = rf"^class {re.escape(return_type_name)}\(TypedDict"
354
360
  class_match = bool(re.search(class_pattern, args_def, re.MULTILINE))
355
- return basic_match or class_match
361
+ return basic_match or class_match
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyapi-python
3
- Version: 0.3.16
3
+ Version: 0.3.17.dev1
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -12,7 +12,7 @@ polyapi/error_handler.py,sha256=I_e0iz6VM23FLVQWJljxs2NGcl_OODbi43OcbnqBlp8,2398
12
12
  polyapi/exceptions.py,sha256=Zh7i7eCUhDuXEdUYjatkLFTeZkrx1BJ1P5ePgbJ9eIY,89
13
13
  polyapi/execute.py,sha256=MeAmc5qsMQfnQPiHJK9Khkn_wrBxMoyMYYqmuFFPsRg,8779
14
14
  polyapi/function_cli.py,sha256=kKrecKCDNMmYtcOOCVF2KKOGjFUfWD2TbiVsyYQ84y8,4323
15
- polyapi/generate.py,sha256=TjMlxxjWN1WnFEmOjSygFcl9RkHCZeCq79R-K_7GYRU,21059
15
+ polyapi/generate.py,sha256=Bti1GlCi6yzv8pqsnJ95_KDES-L_1jwYGmsugZ4_hhA,21271
16
16
  polyapi/http_client.py,sha256=Pd6FYHGB6plWlBbwZD9LPP6FEicdp0wyLWHd_9jxsaY,2273
17
17
  polyapi/parser.py,sha256=pAkeuwp1Kn6bHXiIoj-DuXQ518PztQThIa8vztgsKLQ,21525
18
18
  polyapi/poly_schemas.py,sha256=fZ6AGvHcOKQJtlrzSuzeBNed5DxPMA2dJGdJvuFCHWM,9066
@@ -24,11 +24,11 @@ polyapi/schema.py,sha256=2ehUgs4IcNvqsg5cUjZReg-X83hbh4l0eStKmJhFsBY,5921
24
24
  polyapi/server.py,sha256=35l3f9d6jWaa60MfX5n7KF4UCAQR-Xg8WLc0NL9dlfY,2479
25
25
  polyapi/sync.py,sha256=t0Khh8B5GylxB7KWRP_xvkrvkuyVarSLCOvtmaz7lcc,6766
26
26
  polyapi/typedefs.py,sha256=mfll-KrngOW0wzbvDNiIDaDkFMwbsT-MY5y5hzWj9RE,5642
27
- polyapi/utils.py,sha256=VN8n_jvphderplI5MDYjSutxVnYbJjHhJznYkwjgstw,13349
27
+ polyapi/utils.py,sha256=Z4zx43bJ09ihKhcSrwXKcQrIFLUkF-0rEWI6PyqQ-rA,13542
28
28
  polyapi/variables.py,sha256=hfSDPGQK6YphNCa9MqE0W88WIFfqCQWgpBDWkExMq-A,7582
29
29
  polyapi/webhook.py,sha256=0ceLwHNjNd2Yx_8MX5jOIxiQ5Lwhy2pe81ProAuKon0,5108
30
- polyapi_python-0.3.16.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
31
- polyapi_python-0.3.16.dist-info/METADATA,sha256=6cpwjHGYw4FUgfcoCI_isd-JYAm52BZDzr-KrqST1qs,5923
32
- polyapi_python-0.3.16.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
33
- polyapi_python-0.3.16.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
34
- polyapi_python-0.3.16.dist-info/RECORD,,
30
+ polyapi_python-0.3.17.dev1.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
31
+ polyapi_python-0.3.17.dev1.dist-info/METADATA,sha256=sc2djIZTQDXcshC1I3SBuDv0ec6lABq4ZP7BAEee8PM,5928
32
+ polyapi_python-0.3.17.dev1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
33
+ polyapi_python-0.3.17.dev1.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
34
+ polyapi_python-0.3.17.dev1.dist-info/RECORD,,