polyapi-python 0.2.4.dev6__tar.gz → 0.2.4.dev8__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.
Files changed (37) hide show
  1. {polyapi_python-0.2.4.dev6/polyapi_python.egg-info → polyapi_python-0.2.4.dev8}/PKG-INFO +1 -1
  2. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/function_cli.py +46 -14
  3. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/webhook.py +1 -1
  4. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8/polyapi_python.egg-info}/PKG-INFO +1 -1
  5. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/pyproject.toml +1 -1
  6. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/LICENSE +0 -0
  7. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/README.md +0 -0
  8. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/__init__.py +0 -0
  9. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/__main__.py +0 -0
  10. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/api.py +0 -0
  11. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/auth.py +0 -0
  12. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/cli.py +0 -0
  13. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/client.py +0 -0
  14. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/config.py +0 -0
  15. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/constants.py +0 -0
  16. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/error_handler.py +0 -0
  17. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/exceptions.py +0 -0
  18. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/execute.py +0 -0
  19. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/generate.py +0 -0
  20. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/poly_custom.py +0 -0
  21. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/py.typed +0 -0
  22. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/schema.py +0 -0
  23. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/server.py +0 -0
  24. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/typedefs.py +0 -0
  25. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/utils.py +0 -0
  26. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi/variables.py +0 -0
  27. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi_python.egg-info/SOURCES.txt +0 -0
  28. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi_python.egg-info/dependency_links.txt +0 -0
  29. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi_python.egg-info/requires.txt +0 -0
  30. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/polyapi_python.egg-info/top_level.txt +0 -0
  31. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/setup.cfg +0 -0
  32. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/tests/test_api.py +0 -0
  33. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/tests/test_auth.py +0 -0
  34. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/tests/test_function_cli.py +0 -0
  35. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/tests/test_server.py +0 -0
  36. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/tests/test_utils.py +0 -0
  37. {polyapi_python-0.2.4.dev6 → polyapi_python-0.2.4.dev8}/tests/test_variables.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.2.4.dev6
3
+ Version: 0.2.4.dev8
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
@@ -4,6 +4,7 @@ import json
4
4
  import types
5
5
  import sys
6
6
  from typing import Dict, List, Mapping, Optional, Tuple
7
+ from typing import _TypedDictMeta as BaseTypedDict # type: ignore
7
8
  from typing_extensions import _TypedDictMeta # type: ignore
8
9
  import requests
9
10
  from stdlib_list import stdlib_list
@@ -18,9 +19,18 @@ import importlib
18
19
 
19
20
  # these libraries are already installed in the base docker image
20
21
  # and shouldnt be included in additional requirements
21
- BASE_REQUIREMENTS = {"polyapi", "requests", "typing_extensions", "jsonschema-gentypes", "pydantic", "cloudevents"}
22
- all_stdlib_symbols = stdlib_list('.'.join([str(v) for v in sys.version_info[0:2]]))
23
- BASE_REQUIREMENTS.update(all_stdlib_symbols) # dont need to pip install stuff in the python standard library
22
+ BASE_REQUIREMENTS = {
23
+ "polyapi",
24
+ "requests",
25
+ "typing_extensions",
26
+ "jsonschema-gentypes",
27
+ "pydantic",
28
+ "cloudevents",
29
+ }
30
+ all_stdlib_symbols = stdlib_list(".".join([str(v) for v in sys.version_info[0:2]]))
31
+ BASE_REQUIREMENTS.update(
32
+ all_stdlib_symbols
33
+ ) # dont need to pip install stuff in the python standard library
24
34
 
25
35
 
26
36
  def _get_schemas(code: str) -> List[Dict]:
@@ -28,7 +38,14 @@ def _get_schemas(code: str) -> List[Dict]:
28
38
  user_code = types.SimpleNamespace()
29
39
  exec(code, user_code.__dict__)
30
40
  for name, obj in user_code.__dict__.items():
31
- if (
41
+ if isinstance(obj, BaseTypedDict):
42
+ print_red("ERROR")
43
+ print_red("\nERROR DETAILS: ")
44
+ print(
45
+ "It looks like you have used TypedDict in a custom function. Please use `from typing_extensions import TypedDict` instead. The `typing_extensions` version is more powerful and better allows us to provide rich types for your function."
46
+ )
47
+ sys.exit(1)
48
+ elif (
32
49
  isinstance(obj, type)
33
50
  and isinstance(obj, _TypedDictMeta)
34
51
  and name != "TypedDict"
@@ -76,6 +93,13 @@ def get_python_type_from_ast(expr: ast.expr) -> str:
76
93
  if name == "List":
77
94
  slice = getattr(expr.slice, "id", "Any")
78
95
  return f"List[{slice}]"
96
+ elif name == "Dict":
97
+ if expr.slice and isinstance(expr.slice, ast.Tuple):
98
+ key = get_python_type_from_ast(expr.slice.dims[0])
99
+ value = get_python_type_from_ast(expr.slice.dims[1])
100
+ return f"Dict[{key}, {value}]"
101
+ else:
102
+ return "Dict"
79
103
  return "Any"
80
104
  else:
81
105
  return "Any"
@@ -104,7 +128,9 @@ def _get_type(expr: ast.expr | None, schemas: List[Dict]) -> Tuple[str, Dict | N
104
128
  return json_type, _get_type_schema(json_type, python_type, schemas)
105
129
 
106
130
 
107
- def _get_req_name_if_not_in_base(n: Optional[str], pip_name_lookup: Mapping[str, List[str]]) -> Optional[str]:
131
+ def _get_req_name_if_not_in_base(
132
+ n: Optional[str], pip_name_lookup: Mapping[str, List[str]]
133
+ ) -> Optional[str]:
108
134
  if not n:
109
135
  return None
110
136
 
@@ -175,7 +201,12 @@ def _func_already_exists(context: str, function_name: str) -> bool:
175
201
 
176
202
 
177
203
  def function_add_or_update(
178
- context: str, description: str, client: bool, server: bool, logs_enabled: bool, subcommands: List
204
+ context: str,
205
+ description: str,
206
+ client: bool,
207
+ server: bool,
208
+ logs_enabled: bool,
209
+ subcommands: List,
179
210
  ):
180
211
  parser = argparse.ArgumentParser()
181
212
  parser.add_argument("subcommand", choices=["add"])
@@ -191,16 +222,15 @@ def function_add_or_update(
191
222
  code = f.read()
192
223
 
193
224
  # OK! let's parse the code and generate the arguments
194
- (
195
- arguments,
196
- return_type,
197
- return_type_schema,
198
- requirements
199
- ) = _parse_code(code, args.function_name)
225
+ (arguments, return_type, return_type_schema, requirements) = _parse_code(
226
+ code, args.function_name
227
+ )
200
228
 
201
229
  if not return_type:
202
230
  print_red("ERROR")
203
- print(f"Function {args.function_name} not found as top-level function in {args.filename}")
231
+ print(
232
+ f"Function {args.function_name} not found as top-level function in {args.filename}"
233
+ )
204
234
  sys.exit(1)
205
235
 
206
236
  data = {
@@ -216,7 +246,9 @@ def function_add_or_update(
216
246
  }
217
247
 
218
248
  if server and requirements:
219
- print_yellow('\nPlease note that deploying your functions will take a few minutes because it makes use of libraries other than polyapi.')
249
+ print_yellow(
250
+ "\nPlease note that deploying your functions will take a few minutes because it makes use of libraries other than polyapi."
251
+ )
220
252
  data["requirements"] = requirements
221
253
 
222
254
  api_key, api_url = get_api_key_and_url()
@@ -77,7 +77,7 @@ async def get_client_and_connect():
77
77
 
78
78
 
79
79
  async def unregister(data: Dict[str, Any]):
80
- print(f"stopping error handler for '{data['webhookHandleID']}'...")
80
+ print(f"stopping webhook handler for '{data['webhookHandleID']}'...")
81
81
  assert client
82
82
  await client.emit(
83
83
  "unregisterWebhookEventHandler",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.2.4.dev6
3
+ Version: 0.2.4.dev8
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
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
3
3
 
4
4
  [project]
5
5
  name = "polyapi-python"
6
- version = "0.2.4.dev6"
6
+ version = "0.2.4.dev8"
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 = [