polyapi-python 0.3.2.dev0__tar.gz → 0.3.2.dev2__tar.gz
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_python-0.3.2.dev0/polyapi_python.egg-info → polyapi_python-0.3.2.dev2}/PKG-INFO +2 -2
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/deployables.py +1 -1
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/function_cli.py +0 -1
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/parser.py +7 -6
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2/polyapi_python.egg-info}/PKG-INFO +2 -2
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi_python.egg-info/requires.txt +1 -1
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/pyproject.toml +2 -2
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_deployables.py +11 -1
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_parser.py +22 -3
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/LICENSE +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/README.md +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/__init__.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/__main__.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/api.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/auth.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/cli.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/client.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/config.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/constants.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/error_handler.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/exceptions.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/execute.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/generate.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/prepare.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/py.typed +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/rendered_spec.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/schema.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/server.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/sync.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/typedefs.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/utils.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/variables.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi/webhook.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi_python.egg-info/SOURCES.txt +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi_python.egg-info/dependency_links.txt +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi_python.egg-info/top_level.txt +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/setup.cfg +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_api.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_auth.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_rendered_spec.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_schema.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_server.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_utils.py +0 -0
- {polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/tests/test_variables.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: polyapi-python
|
|
3
|
-
Version: 0.3.2.
|
|
3
|
+
Version: 0.3.2.dev2
|
|
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
|
|
@@ -29,7 +29,7 @@ Requires-Python: >=3.10
|
|
|
29
29
|
Description-Content-Type: text/markdown
|
|
30
30
|
License-File: LICENSE
|
|
31
31
|
Requires-Dist: requests==2.31.0
|
|
32
|
-
Requires-Dist: typing_extensions
|
|
32
|
+
Requires-Dist: typing_extensions>=4.10.0
|
|
33
33
|
Requires-Dist: jsonschema-gentypes==2.6.0
|
|
34
34
|
Requires-Dist: pydantic==2.6.4
|
|
35
35
|
Requires-Dist: stdlib_list==0.10.0
|
|
@@ -245,7 +245,7 @@ def update_deployment_comments(file_content: str, deployable: dict) -> str:
|
|
|
245
245
|
if deployable['deployments']:
|
|
246
246
|
deployment_comments = write_deploy_comments(deployable['deployments'])
|
|
247
247
|
deployable['deploymentCommentRanges'] = [(0, len(deployment_comments) + 1)]
|
|
248
|
-
file_content = f"{deployment_comments}{file_content}"
|
|
248
|
+
file_content = f"{deployment_comments}\n{file_content}"
|
|
249
249
|
return file_content
|
|
250
250
|
|
|
251
251
|
def update_deployable_function_comments(file_content: str, deployable: dict, disable_docs: bool = False) -> str:
|
|
@@ -55,7 +55,6 @@ def function_add_or_update(
|
|
|
55
55
|
"code": code,
|
|
56
56
|
"language": "python",
|
|
57
57
|
"returnType": get_jsonschema_type(return_type),
|
|
58
|
-
"returnTypeSchema": parsed["types"]["returns"]["typeSchema"],
|
|
59
58
|
"arguments": [{**p, "key": p["name"], "type": get_jsonschema_type(p["type"]) } for p in parsed["types"]["params"]],
|
|
60
59
|
"logsEnabled": logs_enabled,
|
|
61
60
|
}
|
|
@@ -181,7 +181,7 @@ def _get_schemas(code: str) -> List[Dict]:
|
|
|
181
181
|
|
|
182
182
|
def get_jsonschema_type(python_type: str):
|
|
183
183
|
if python_type == "Any":
|
|
184
|
-
return "
|
|
184
|
+
return "any"
|
|
185
185
|
|
|
186
186
|
if python_type == "List":
|
|
187
187
|
return "array"
|
|
@@ -338,6 +338,7 @@ def parse_function_code(code: str, name: Optional[str] = "", context: Optional[s
|
|
|
338
338
|
"params": [],
|
|
339
339
|
"returns": {
|
|
340
340
|
"type": "",
|
|
341
|
+
"typeSchema": None,
|
|
341
342
|
"description": "",
|
|
342
343
|
}
|
|
343
344
|
},
|
|
@@ -435,13 +436,14 @@ def parse_function_code(code: str, name: Optional[str] = "", context: Optional[s
|
|
|
435
436
|
|
|
436
437
|
def _extract_deploy_comments(self):
|
|
437
438
|
for i in range(len(self._lines)):
|
|
438
|
-
line = self._lines[i]
|
|
439
|
+
line = self._lines[i]
|
|
439
440
|
if line and not line.startswith("#"):
|
|
440
441
|
return
|
|
441
|
-
deployment = _parse_deploy_comment(line)
|
|
442
|
+
deployment = _parse_deploy_comment(line.strip())
|
|
442
443
|
if deployment:
|
|
444
|
+
start = self._line_offsets[i]
|
|
443
445
|
deployable["deployments"].append(deployment)
|
|
444
|
-
deployable["deploymentCommentRanges"].append([
|
|
446
|
+
deployable["deploymentCommentRanges"].append([start, start + len(line)])
|
|
445
447
|
|
|
446
448
|
def visit_Import(self, node: ast.Import):
|
|
447
449
|
# TODO maybe handle `import foo.bar` case?
|
|
@@ -471,8 +473,7 @@ def parse_function_code(code: str, name: Optional[str] = "", context: Optional[s
|
|
|
471
473
|
"type": python_type,
|
|
472
474
|
"description": "",
|
|
473
475
|
}
|
|
474
|
-
if type_schema
|
|
475
|
-
json_arg["typeSchema"] = json.dumps(type_schema)
|
|
476
|
+
json_arg["typeSchema"] = json.dumps(type_schema) if type_schema else None
|
|
476
477
|
|
|
477
478
|
if docstring_params:
|
|
478
479
|
try:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: polyapi-python
|
|
3
|
-
Version: 0.3.2.
|
|
3
|
+
Version: 0.3.2.dev2
|
|
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
|
|
@@ -29,7 +29,7 @@ Requires-Python: >=3.10
|
|
|
29
29
|
Description-Content-Type: text/markdown
|
|
30
30
|
License-File: LICENSE
|
|
31
31
|
Requires-Dist: requests==2.31.0
|
|
32
|
-
Requires-Dist: typing_extensions
|
|
32
|
+
Requires-Dist: typing_extensions>=4.10.0
|
|
33
33
|
Requires-Dist: jsonschema-gentypes==2.6.0
|
|
34
34
|
Requires-Dist: pydantic==2.6.4
|
|
35
35
|
Requires-Dist: stdlib_list==0.10.0
|
|
@@ -3,12 +3,12 @@ requires = ["setuptools>=61.2", "wheel"]
|
|
|
3
3
|
|
|
4
4
|
[project]
|
|
5
5
|
name = "polyapi-python"
|
|
6
|
-
version = "0.3.2.
|
|
6
|
+
version = "0.3.2.dev2"
|
|
7
7
|
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
|
|
8
8
|
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
|
|
9
9
|
dependencies = [
|
|
10
10
|
"requests==2.31.0",
|
|
11
|
-
"typing_extensions
|
|
11
|
+
"typing_extensions>=4.10.0",
|
|
12
12
|
"jsonschema-gentypes==2.6.0",
|
|
13
13
|
"pydantic==2.6.4",
|
|
14
14
|
"stdlib_list==0.10.0",
|
|
@@ -21,6 +21,7 @@ def foobar() -> int:
|
|
|
21
21
|
|
|
22
22
|
EXPECTED_SERVER_FN_DEPLOYMENTS = '''# Poly deployed @ 2024-11-12T14:43:22.631113 - testing.foobar - https://na1.polyapi.io/canopy/polyui/collections/server-functions/jh23h5g3h5b24jh5b2j3h45v2jhg43v52j3h - 086aedd
|
|
23
23
|
# Poly deployed @ 2024-11-11T14:43:22.631113 - testing.foobar - https://dev.polyapi.io/canopy/polyui/collections/server-functions/jh23h5g3h5b24jh5b2j3h45v2jhg43v52j3h - 086aedd
|
|
24
|
+
|
|
24
25
|
from polyapi.typedefs import PolyServerFunction
|
|
25
26
|
|
|
26
27
|
polyConfig: PolyServerFunction = {
|
|
@@ -76,6 +77,15 @@ def foobar(foo: str, bar: Dict[str, str]) -> int:
|
|
|
76
77
|
'''
|
|
77
78
|
|
|
78
79
|
class T(unittest.TestCase):
|
|
80
|
+
def test_parse_and_write_deployment_comment(self):
|
|
81
|
+
test_deployable = parse_function_code(EXPECTED_SERVER_FN_DEPLOYMENTS, "foobar")
|
|
82
|
+
deployable_comment_ranges = test_deployable["deploymentCommentRanges"]
|
|
83
|
+
updated_file_contents = update_deployment_comments(EXPECTED_SERVER_FN_DEPLOYMENTS, test_deployable)
|
|
84
|
+
self.assertEqual(updated_file_contents, EXPECTED_SERVER_FN_DEPLOYMENTS)
|
|
85
|
+
# Deployment comment ranges collapsed into one of equal size
|
|
86
|
+
self.assertEqual(test_deployable["deploymentCommentRanges"][0][0], deployable_comment_ranges[0][0])
|
|
87
|
+
self.assertEqual(test_deployable["deploymentCommentRanges"][0][1], deployable_comment_ranges[1][1])
|
|
88
|
+
|
|
79
89
|
def test_write_deployment_comment(self):
|
|
80
90
|
test_deployable = {
|
|
81
91
|
"deployments": [
|
|
@@ -98,7 +108,7 @@ class T(unittest.TestCase):
|
|
|
98
108
|
'type': 'server-function'
|
|
99
109
|
}
|
|
100
110
|
],
|
|
101
|
-
"deploymentCommentRanges": [[0,
|
|
111
|
+
"deploymentCommentRanges": [[0, 177]]
|
|
102
112
|
}
|
|
103
113
|
updated_file_contents = update_deployment_comments(INITIAL_SERVER_FN_DEPLOYMENTS, test_deployable)
|
|
104
114
|
self.assertEqual(updated_file_contents, EXPECTED_SERVER_FN_DEPLOYMENTS)
|
|
@@ -3,6 +3,11 @@ import unittest
|
|
|
3
3
|
from polyapi.parser import parse_function_code
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
CODE_NO_TYPES = """
|
|
7
|
+
def foobar(a, b):
|
|
8
|
+
return a + b
|
|
9
|
+
"""
|
|
10
|
+
|
|
6
11
|
SIMPLE_CODE = """
|
|
7
12
|
def foobar(n: int) -> int:
|
|
8
13
|
return 9
|
|
@@ -124,11 +129,21 @@ def foobar(foo: str, bar: Dict[str, str]) -> int:
|
|
|
124
129
|
'''
|
|
125
130
|
|
|
126
131
|
class T(unittest.TestCase):
|
|
132
|
+
def test_no_types(self):
|
|
133
|
+
deployable = parse_function_code(CODE_NO_TYPES, "foobar")
|
|
134
|
+
types = deployable["types"]
|
|
135
|
+
self.assertEqual(len(types["params"]), 2)
|
|
136
|
+
self.assertEqual(types["params"][0], {"name": "a", "type": "Any", "typeSchema": None, "description": ""})
|
|
137
|
+
self.assertEqual(types["params"][1], {"name": "b", "type": "Any", "typeSchema": None, "description": ""})
|
|
138
|
+
self.assertEqual(types["returns"]["type"], "Any")
|
|
139
|
+
self.assertIsNone(types["returns"]["typeSchema"])
|
|
140
|
+
self.assertEqual(deployable["dependencies"], [])
|
|
141
|
+
|
|
127
142
|
def test_simple_types(self):
|
|
128
143
|
deployable = parse_function_code(SIMPLE_CODE, "foobar")
|
|
129
144
|
types = deployable["types"]
|
|
130
145
|
self.assertEqual(len(types["params"]), 1)
|
|
131
|
-
self.assertEqual(types["params"][0], {"name": "n", "type": "int", "description": ""})
|
|
146
|
+
self.assertEqual(types["params"][0], {"name": "n", "type": "int", "typeSchema": None, "description": ""})
|
|
132
147
|
self.assertEqual(types["returns"]["type"], "int")
|
|
133
148
|
self.assertIsNone(types["returns"]["typeSchema"])
|
|
134
149
|
self.assertEqual(deployable["dependencies"], [])
|
|
@@ -137,7 +152,7 @@ class T(unittest.TestCase):
|
|
|
137
152
|
deployable = parse_function_code(COMPLEX_RETURN_TYPE, "foobar")
|
|
138
153
|
types = deployable["types"]
|
|
139
154
|
self.assertEqual(len(types["params"]), 1)
|
|
140
|
-
self.assertEqual(types["params"][0], {"name": "n", "type": "int", "description": ""})
|
|
155
|
+
self.assertEqual(types["params"][0], {"name": "n", "type": "int", "typeSchema": None, "description": ""})
|
|
141
156
|
self.assertEqual(types["returns"]["type"], "Barbar")
|
|
142
157
|
self.assertEqual(types["returns"]["typeSchema"]['title'], "Barbar")
|
|
143
158
|
|
|
@@ -153,7 +168,7 @@ class T(unittest.TestCase):
|
|
|
153
168
|
deployable = parse_function_code(LIST_COMPLEX_RETURN_TYPE, "foobar")
|
|
154
169
|
types = deployable["types"]
|
|
155
170
|
self.assertEqual(len(types["params"]), 1)
|
|
156
|
-
self.assertEqual(types["params"][0], {"name": "n", "type": "int", "description": ""})
|
|
171
|
+
self.assertEqual(types["params"][0], {"name": "n", "type": "int", "typeSchema": None, "description": ""})
|
|
157
172
|
self.assertEqual(types["returns"]["type"], "List[Barbar]")
|
|
158
173
|
self.assertEqual(types["returns"]["typeSchema"]["items"]['title'], "Barbar")
|
|
159
174
|
|
|
@@ -186,11 +201,13 @@ class T(unittest.TestCase):
|
|
|
186
201
|
self.assertEqual(deployable["types"]["params"][0], {
|
|
187
202
|
"name": "foo",
|
|
188
203
|
"type": "Any",
|
|
204
|
+
"typeSchema": None,
|
|
189
205
|
"description": "The foo in question"
|
|
190
206
|
})
|
|
191
207
|
self.assertEqual(deployable["types"]["params"][1], {
|
|
192
208
|
"name": "bar",
|
|
193
209
|
"type": "Any",
|
|
210
|
+
"typeSchema": None,
|
|
194
211
|
"description": "Configuration of bars"
|
|
195
212
|
})
|
|
196
213
|
self.assertEqual(deployable["types"]["returns"], {
|
|
@@ -205,11 +222,13 @@ class T(unittest.TestCase):
|
|
|
205
222
|
self.assertEqual(deployable["types"]["params"][0], {
|
|
206
223
|
"name": "foo",
|
|
207
224
|
"type": "str",
|
|
225
|
+
"typeSchema": None,
|
|
208
226
|
"description": "The foo in question"
|
|
209
227
|
})
|
|
210
228
|
self.assertEqual(deployable["types"]["params"][1], {
|
|
211
229
|
"name": "bar",
|
|
212
230
|
"type": "Dict[str, str]",
|
|
231
|
+
"typeSchema": None,
|
|
213
232
|
"description": "Configuration of bars"
|
|
214
233
|
})
|
|
215
234
|
self.assertEqual(deployable["types"]["returns"], {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{polyapi_python-0.3.2.dev0 → polyapi_python-0.3.2.dev2}/polyapi_python.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|