polyapi-python 0.3.8.dev3__py3-none-any.whl → 0.3.8.dev5__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/client.py +4 -4
- polyapi/generate.py +8 -9
- {polyapi_python-0.3.8.dev3.dist-info → polyapi_python-0.3.8.dev5.dist-info}/METADATA +1 -1
- {polyapi_python-0.3.8.dev3.dist-info → polyapi_python-0.3.8.dev5.dist-info}/RECORD +7 -7
- {polyapi_python-0.3.8.dev3.dist-info → polyapi_python-0.3.8.dev5.dist-info}/WHEEL +0 -0
- {polyapi_python-0.3.8.dev3.dist-info → polyapi_python-0.3.8.dev5.dist-info}/licenses/LICENSE +0 -0
- {polyapi_python-0.3.8.dev3.dist-info → polyapi_python-0.3.8.dev5.dist-info}/top_level.txt +0 -0
polyapi/client.py
CHANGED
|
@@ -10,7 +10,7 @@ from typing import List, Dict, Any, TypedDict
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
def _wrap_code_in_try_except(code: str) -> str:
|
|
13
|
+
def _wrap_code_in_try_except(function_name: str, code: str) -> str:
|
|
14
14
|
""" this is necessary because client functions with imports will blow up ALL server functions,
|
|
15
15
|
even if they don't use them.
|
|
16
16
|
because the server function will try to load all client functions when loading the library
|
|
@@ -18,8 +18,8 @@ def _wrap_code_in_try_except(code: str) -> str:
|
|
|
18
18
|
prefix = """logger = logging.getLogger("poly")
|
|
19
19
|
try:
|
|
20
20
|
"""
|
|
21
|
-
suffix = """except ImportError as e:
|
|
22
|
-
logger.
|
|
21
|
+
suffix = f"""except ImportError as e:
|
|
22
|
+
logger.warning("Failed to import client function '{function_name}', function unavailable: " + str(e))"""
|
|
23
23
|
|
|
24
24
|
lines = code.split("\n")
|
|
25
25
|
code = "\n ".join(lines)
|
|
@@ -39,6 +39,6 @@ def render_client_function(
|
|
|
39
39
|
return_type_def=return_type_def,
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
code = _wrap_code_in_try_except(code)
|
|
42
|
+
code = _wrap_code_in_try_except(function_name, code)
|
|
43
43
|
|
|
44
44
|
return code + "\n\n", func_type_defs
|
polyapi/generate.py
CHANGED
|
@@ -2,7 +2,7 @@ import json
|
|
|
2
2
|
import requests
|
|
3
3
|
import os
|
|
4
4
|
import shutil
|
|
5
|
-
from typing import List, Optional, Tuple, cast
|
|
5
|
+
from typing import Any, List, Optional, Tuple, cast
|
|
6
6
|
|
|
7
7
|
from .auth import render_auth_function
|
|
8
8
|
from .client import render_client_function
|
|
@@ -41,7 +41,7 @@ def get_specs(contexts: Optional[List[str]] = None, names: Optional[List[str]] =
|
|
|
41
41
|
assert api_key
|
|
42
42
|
headers = get_auth_headers(api_key)
|
|
43
43
|
url = f"{api_url}/specs"
|
|
44
|
-
params = {"noTypes": str(no_types).lower()}
|
|
44
|
+
params: Any = {"noTypes": str(no_types).lower()}
|
|
45
45
|
|
|
46
46
|
if contexts:
|
|
47
47
|
params["contexts"] = contexts
|
|
@@ -155,7 +155,7 @@ def parse_function_specs(
|
|
|
155
155
|
|
|
156
156
|
# Functions with serverSideAsync True will always return a Dict with execution ID
|
|
157
157
|
if spec.get('serverSideAsync') and spec.get("function"):
|
|
158
|
-
spec['function']['returnType'] = {'kind': 'plain', 'value': 'object'}
|
|
158
|
+
spec['function']['returnType'] = {'kind': 'plain', 'value': 'object'} # type: ignore
|
|
159
159
|
|
|
160
160
|
functions.append(spec)
|
|
161
161
|
|
|
@@ -321,11 +321,9 @@ def generate(contexts: Optional[List[str]] = None, names: Optional[List[str]] =
|
|
|
321
321
|
)
|
|
322
322
|
exit()
|
|
323
323
|
|
|
324
|
-
|
|
325
|
-
if
|
|
326
|
-
variables
|
|
327
|
-
if variables:
|
|
328
|
-
generate_variables(variables)
|
|
324
|
+
variables = get_variables()
|
|
325
|
+
if variables:
|
|
326
|
+
generate_variables(variables)
|
|
329
327
|
|
|
330
328
|
# indicator to vscode extension that this is a polyapi-python project
|
|
331
329
|
file_path = os.path.join(os.getcwd(), ".polyapi-python")
|
|
@@ -354,8 +352,9 @@ def render_spec(spec: SpecificationDto) -> Tuple[str, str]:
|
|
|
354
352
|
function_id = spec["id"]
|
|
355
353
|
|
|
356
354
|
arguments: List[PropertySpecification] = []
|
|
357
|
-
return_type = {}
|
|
355
|
+
return_type: Any = {}
|
|
358
356
|
if spec.get("function"):
|
|
357
|
+
assert spec["function"]
|
|
359
358
|
# Handle cases where arguments might be missing or None
|
|
360
359
|
if spec["function"].get("arguments"):
|
|
361
360
|
arguments = [
|
|
@@ -3,7 +3,7 @@ polyapi/__main__.py,sha256=V4zhAh_YGxno5f_KSrlkELxcuDh9bR3WSd0n-2r-qQQ,93
|
|
|
3
3
|
polyapi/api.py,sha256=2nds6ZdNe9OHvCba4IjOPga0CAYIsib2SbhEyDDCmd8,2188
|
|
4
4
|
polyapi/auth.py,sha256=zrIGatjba5GwUTNjKj1GHQWTEDP9B-HrSzCKbLFoqvc,5336
|
|
5
5
|
polyapi/cli.py,sha256=NcLXOUdkcXgsFboO5PXwncK4uzGLu1mIXJDUn5NUgKo,10192
|
|
6
|
-
polyapi/client.py,sha256=
|
|
6
|
+
polyapi/client.py,sha256=DW6ljG_xCwAo2yz23A9QfLooE6ZUDvSpdA4e_dCQjiQ,1418
|
|
7
7
|
polyapi/config.py,sha256=cAMv2n9tGN_BTvqt7V32o5F86qRhxAKyey_PoId2D8s,7638
|
|
8
8
|
polyapi/constants.py,sha256=sc-FnS0SngBLvSu1ZWMs0UCf9EYD1u1Yhfr-sZXGLns,607
|
|
9
9
|
polyapi/deployables.py,sha256=KjVAillK3OMNpT2F5KzmAefoTSmhDN0ZIwzEMXPCRU0,12261
|
|
@@ -11,7 +11,7 @@ polyapi/error_handler.py,sha256=I_e0iz6VM23FLVQWJljxs2NGcl_OODbi43OcbnqBlp8,2398
|
|
|
11
11
|
polyapi/exceptions.py,sha256=Zh7i7eCUhDuXEdUYjatkLFTeZkrx1BJ1P5ePgbJ9eIY,89
|
|
12
12
|
polyapi/execute.py,sha256=sjI6BMBYPSCD6UngV9DzpJIRSU6p02aShNaTXhDExtY,3457
|
|
13
13
|
polyapi/function_cli.py,sha256=H0sVrbvRBXw_xeApe2MvQw8p_xE7jVTTOU-07Dg041A,4220
|
|
14
|
-
polyapi/generate.py,sha256=
|
|
14
|
+
polyapi/generate.py,sha256=rzRb9TW5VjdqT13beIezQratdfAvE7yYWX_ODlZJTK0,16105
|
|
15
15
|
polyapi/parser.py,sha256=mdoh4pNq8pyiHE0-i6Coqj8frEXfBLRk6itpAXMrrgI,20373
|
|
16
16
|
polyapi/poly_schemas.py,sha256=T4kfZyfgVLiqLD28GmYNiHnrNx77J_HO4uzk8LUAhlo,3137
|
|
17
17
|
polyapi/prepare.py,sha256=t-Gj5SrLokUuAJ70IKY6myK_OoJ-N7SazeIMlu5cmuc,7396
|
|
@@ -24,8 +24,8 @@ polyapi/typedefs.py,sha256=MGDwWaijLNqokXF9UCHGAP-yKixOzztrH4Lsj800AJs,2328
|
|
|
24
24
|
polyapi/utils.py,sha256=1F7Dwst_PbPuUBUSxx5r8d2DHDgqHtu07QW92T_YSdw,12454
|
|
25
25
|
polyapi/variables.py,sha256=j7WWrGLr2O5SkWGxnsusnnfl25kVL3b6SQYcVGEoC8c,4277
|
|
26
26
|
polyapi/webhook.py,sha256=NTSXYOl_QqsFekWRepPyVTsV9SVkgUu0HfG1SJJDHOE,4958
|
|
27
|
-
polyapi_python-0.3.8.
|
|
28
|
-
polyapi_python-0.3.8.
|
|
29
|
-
polyapi_python-0.3.8.
|
|
30
|
-
polyapi_python-0.3.8.
|
|
31
|
-
polyapi_python-0.3.8.
|
|
27
|
+
polyapi_python-0.3.8.dev5.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
|
|
28
|
+
polyapi_python-0.3.8.dev5.dist-info/METADATA,sha256=3m0BmPbTE504NOJ1A0fl-ueXzgUlu1Oj03XDw8egBFQ,5782
|
|
29
|
+
polyapi_python-0.3.8.dev5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
polyapi_python-0.3.8.dev5.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
|
|
31
|
+
polyapi_python-0.3.8.dev5.dist-info/RECORD,,
|
|
File without changes
|
{polyapi_python-0.3.8.dev3.dist-info → polyapi_python-0.3.8.dev5.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|