polyapi-python 0.2.7.dev3__py3-none-any.whl → 0.2.7.dev4__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/api.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, List, Tuple
2
2
 
3
3
  from polyapi.typedefs import PropertySpecification
4
- from polyapi.utils import add_type_import_path, camelCase, parse_arguments, get_type_and_def
4
+ from polyapi.utils import add_type_import_path, parse_arguments, get_type_and_def, rewrite_arg_name
5
5
 
6
6
 
7
7
  API_DEFS_TEMPLATE = """
@@ -41,7 +41,7 @@ def render_api_function(
41
41
  arg_names = [a["name"] for a in arguments]
42
42
  args, args_def = parse_arguments(function_name, arguments)
43
43
  return_type_name, return_type_def = get_type_and_def(return_type) # type: ignore
44
- data = "{" + ", ".join([f"'{arg}': {camelCase(arg)}" for arg in arg_names]) + "}"
44
+ data = "{" + ", ".join([f"'{arg}': {rewrite_arg_name(arg)}" for arg in arg_names]) + "}"
45
45
 
46
46
  api_response_type = f"{function_name}Response"
47
47
  func_type_defs = API_DEFS_TEMPLATE.format(
polyapi/client.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, List, Tuple
2
2
 
3
3
  from polyapi.typedefs import PropertySpecification
4
- from polyapi.utils import camelCase, add_type_import_path, parse_arguments, get_type_and_def
4
+ from polyapi.utils import parse_arguments, get_type_and_def
5
5
 
6
6
  DEFS_TEMPLATE = """
7
7
  from typing import List, Dict, Any, TypedDict
polyapi/server.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, List, Tuple
2
2
 
3
3
  from polyapi.typedefs import PropertySpecification
4
- from polyapi.utils import camelCase, add_type_import_path, parse_arguments, get_type_and_def
4
+ from polyapi.utils import add_type_import_path, parse_arguments, get_type_and_def, rewrite_arg_name
5
5
 
6
6
  SERVER_DEFS_TEMPLATE = """
7
7
  from typing import List, Dict, Any, TypedDict, Callable
@@ -38,7 +38,7 @@ def render_server_function(
38
38
  arg_names = [a["name"] for a in arguments]
39
39
  args, args_def = parse_arguments(function_name, arguments)
40
40
  return_type_name, return_type_def = get_type_and_def(return_type) # type: ignore
41
- data = "{" + ", ".join([f"'{arg}': {camelCase(arg)}" for arg in arg_names]) + "}"
41
+ data = "{" + ", ".join([f"'{arg}': {rewrite_arg_name(arg)}" for arg in arg_names]) + "}"
42
42
  func_type_defs = SERVER_DEFS_TEMPLATE.format(
43
43
  args_def=args_def,
44
44
  return_type_def=return_type_def,
polyapi/utils.py CHANGED
@@ -1,3 +1,4 @@
1
+ import keyword
1
2
  import re
2
3
  import os
3
4
  from typing import Tuple, List
@@ -164,9 +165,10 @@ def parse_arguments(function_name: str, arguments: List[PropertySpecification])
164
165
  arg_type, arg_def = get_type_and_def(a["type"])
165
166
  if arg_def:
166
167
  args_def.append(arg_def)
167
- a["name"] = camelCase(a["name"])
168
+ a["name"] = rewrite_arg_name(a["name"])
168
169
  arg_string += f" {a['name']}: {add_type_import_path(function_name, arg_type)}"
169
170
  description = a.get("description", "")
171
+ description = description.replace("\n", " ")
170
172
  if description:
171
173
  if idx == len(arguments) - 1:
172
174
  arg_string += f" # {description}\n"
@@ -186,7 +188,7 @@ def poly_full_path(context, name) -> str:
186
188
  return f"poly.{path}"
187
189
 
188
190
 
189
- RESERVED_TYPES = {"List", "Dict", "Any", "Optional", "Callable"}
191
+ RESERVED_WORDS = {"List", "Dict", "Any", "Optional", "Callable"} | set(keyword.kwlist)
190
192
 
191
193
 
192
194
  def to_func_namespace(s: str) -> str:
@@ -194,7 +196,16 @@ def to_func_namespace(s: str) -> str:
194
196
  by default it is
195
197
  """
196
198
  rv = s[0].upper() + s[1:]
197
- if rv in RESERVED_TYPES:
198
- return "_" + rv
199
+ rv = rewrite_reserved(rv)
200
+ return rv
201
+
202
+
203
+ def rewrite_reserved(s: str) -> str:
204
+ if s in RESERVED_WORDS:
205
+ return "_" + s
199
206
  else:
200
- return rv
207
+ return s
208
+
209
+
210
+ def rewrite_arg_name(s: str):
211
+ return rewrite_reserved(camelCase(s))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.2.7.dev3
3
+ Version: 0.2.7.dev4
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
@@ -1,9 +1,9 @@
1
1
  polyapi/__init__.py,sha256=5iujRodfgRyLxT-zY0L3xax3rKRvfSt4NZlZYKOz03w,608
2
2
  polyapi/__main__.py,sha256=V4zhAh_YGxno5f_KSrlkELxcuDh9bR3WSd0n-2r-qQQ,93
3
- polyapi/api.py,sha256=bE651P47RuhqNYkVyvTH_pA44JypRZED_2M5UG_qzDI,1863
3
+ polyapi/api.py,sha256=e-8nOzq6SXD7_YPVBlW82_9wVxDCc8XD9ioMv_QvnH0,1877
4
4
  polyapi/auth.py,sha256=zrIGatjba5GwUTNjKj1GHQWTEDP9B-HrSzCKbLFoqvc,5336
5
5
  polyapi/cli.py,sha256=1ZeaK1A0wZM91YLJrYmvSR2wwHRkT7w1p7q9Y0KZu9c,2785
6
- polyapi/client.py,sha256=w15XOABkwdL4V4r2iWY_nypzLjvoKVuux8jUKbA16pQ,1329
6
+ polyapi/client.py,sha256=CoFDYvyKsqL4wPQbUDIr0Qb8Q5eD92xN4OEEcJEVuGQ,1296
7
7
  polyapi/config.py,sha256=S8TU10upy5OW1_vX-CqQTJD-ZOB6329aMjiUCmukfUI,2292
8
8
  polyapi/constants.py,sha256=sc-FnS0SngBLvSu1ZWMs0UCf9EYD1u1Yhfr-sZXGLns,607
9
9
  polyapi/error_handler.py,sha256=I_e0iz6VM23FLVQWJljxs2NGcl_OODbi43OcbnqBlp8,2398
@@ -14,13 +14,13 @@ polyapi/generate.py,sha256=LN2Z6fE-HfpMsXlkJfOl8bqZdR3fUythE_ZsAe15tmk,8012
14
14
  polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  polyapi/rendered_spec.py,sha256=uaNzBhP4cX7iGfKwzZv0dxMagWzsGeDr0cQYx_AyIhQ,2153
16
16
  polyapi/schema.py,sha256=VVMHAT5yU47cRC7xF44BrmUSemlk5oIKSxH2HTVPaQ8,3169
17
- polyapi/server.py,sha256=n-nMGjXoq9T9ZwE2EBDkAaxJ7UytConGaHthkjbkCXA,1894
17
+ polyapi/server.py,sha256=NzQCZFSAJK7XiRw1kiU_i9uMvgYK7i8qh7UX2xjytJU,1908
18
18
  polyapi/typedefs.py,sha256=mRqwd2LKofxNn_VSKxBzixni2j-tai8mfTQ0Wi2aLNM,1487
19
- polyapi/utils.py,sha256=JtL_v0PVkJBlTeRu0gIV5IDScqoiggS8m-VcS4HN22c,6890
19
+ polyapi/utils.py,sha256=PD70FbVLZX0x1Jf2IYZLG2U5XHP6DfYZAwjwlVcl1z8,7141
20
20
  polyapi/variables.py,sha256=d36-trnfTL_8m2NkorMiImb4O3UrJbiFV38CHxV5i0A,4200
21
21
  polyapi/webhook.py,sha256=LWv28c2MLz_OKBI_Nn7WR4C-gs1SWgbdXsoxIIf-9UI,4886
22
- polyapi_python-0.2.7.dev3.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
23
- polyapi_python-0.2.7.dev3.dist-info/METADATA,sha256=TgdRVxzUaQeLRzVzY9sIBSRPT40KZWsUXyDnCuHT7Og,4867
24
- polyapi_python-0.2.7.dev3.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
25
- polyapi_python-0.2.7.dev3.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
26
- polyapi_python-0.2.7.dev3.dist-info/RECORD,,
22
+ polyapi_python-0.2.7.dev4.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
23
+ polyapi_python-0.2.7.dev4.dist-info/METADATA,sha256=6M7yV5HAzf7EKsBiIDd1OiakFED4gu5yJhFQgwDMZPA,4867
24
+ polyapi_python-0.2.7.dev4.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
25
+ polyapi_python-0.2.7.dev4.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
26
+ polyapi_python-0.2.7.dev4.dist-info/RECORD,,