payi 0.1.0a4__py3-none-any.whl → 0.1.0a6__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.

Potentially problematic release.


This version of payi might be problematic. Click here for more details.

payi/_utils/__init__.py CHANGED
@@ -49,4 +49,7 @@ from ._transform import (
49
49
  maybe_transform as maybe_transform,
50
50
  async_maybe_transform as async_maybe_transform,
51
51
  )
52
- from ._reflection import function_has_argument as function_has_argument
52
+ from ._reflection import (
53
+ function_has_argument as function_has_argument,
54
+ assert_signatures_in_sync as assert_signatures_in_sync,
55
+ )
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import inspect
2
4
  from typing import Any, Callable
3
5
 
@@ -6,3 +8,35 @@ def function_has_argument(func: Callable[..., Any], arg_name: str) -> bool:
6
8
  """Returns whether or not the given function has a specific parameter"""
7
9
  sig = inspect.signature(func)
8
10
  return arg_name in sig.parameters
11
+
12
+
13
+ def assert_signatures_in_sync(
14
+ source_func: Callable[..., Any],
15
+ check_func: Callable[..., Any],
16
+ *,
17
+ exclude_params: set[str] = set(),
18
+ ) -> None:
19
+ """Ensure that the signature of the second function matches the first."""
20
+
21
+ check_sig = inspect.signature(check_func)
22
+ source_sig = inspect.signature(source_func)
23
+
24
+ errors: list[str] = []
25
+
26
+ for name, source_param in source_sig.parameters.items():
27
+ if name in exclude_params:
28
+ continue
29
+
30
+ custom_param = check_sig.parameters.get(name)
31
+ if not custom_param:
32
+ errors.append(f"the `{name}` param is missing")
33
+ continue
34
+
35
+ if custom_param.annotation != source_param.annotation:
36
+ errors.append(
37
+ f"types for the `{name}` param are do not match; source={repr(source_param.annotation)} checking={repr(source_param.annotation)}"
38
+ )
39
+ continue
40
+
41
+ if errors:
42
+ raise AssertionError(f"{len(errors)} errors encountered when comparing signatures:\n\n" + "\n\n".join(errors))
payi/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "payi"
4
- __version__ = "0.1.0-alpha.4" # x-release-please-version
4
+ __version__ = "0.1.0-alpha.6" # x-release-please-version
payi/lib/helpers.py ADDED
@@ -0,0 +1,32 @@
1
+ # Step 1: Define the new methods outside of the Payi class definition
2
+ from typing import Dict, List, Union
3
+
4
+
5
+ def create_budget_header_from_ids(budget_ids: List[str]) -> Dict[str, str]:
6
+ if not isinstance(budget_ids, list): # type: ignore
7
+ raise TypeError("budget_ids must be a list")
8
+
9
+ valid_ids = [id.strip() for id in budget_ids if isinstance(id, str) and id.strip()] # type: ignore
10
+
11
+ return {"xProxy-Budget-IDs": ",".join(valid_ids)} if valid_ids else {}
12
+
13
+ def create_request_header_from_tags(request_tags: List[str]) -> Dict[str, str]:
14
+ if not isinstance(request_tags, list): # type: ignore
15
+ raise TypeError("request_tags must be a list")
16
+
17
+ valid_tags = [tag.strip() for tag in request_tags if isinstance(tag, str) and tag.strip()] # type: ignore
18
+
19
+ return {"xProxy-Request-Tags": ",".join(valid_tags)} if valid_tags else {}
20
+
21
+ def create_headers(
22
+ budget_ids: Union[List[str], None] = None,
23
+ request_tags: Union[List[str], None] = None
24
+ ) -> Dict[str, str]:
25
+ headers: Dict[str, str] = {}
26
+
27
+ if budget_ids:
28
+ headers.update(create_budget_header_from_ids(budget_ids))
29
+ if request_tags:
30
+ headers.update(create_request_header_from_tags(request_tags))
31
+
32
+ return headers
payi/resources/ingest.py CHANGED
@@ -43,8 +43,8 @@ class IngestResource(SyncAPIResource):
43
43
  input: int,
44
44
  output: int,
45
45
  resource: str,
46
- budget_ids: str | NotGiven = NOT_GIVEN,
47
- request_tags: str | NotGiven = NOT_GIVEN,
46
+ budget_ids: list[str] | NotGiven = NOT_GIVEN,
47
+ request_tags: list[str] | NotGiven = NOT_GIVEN,
48
48
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
49
49
  # The extra values given here take precedence over values defined on the client or passed to this method.
50
50
  extra_headers: Headers | None = None,
@@ -64,11 +64,27 @@ class IngestResource(SyncAPIResource):
64
64
 
65
65
  timeout: Override the client-level default timeout for this request, in seconds
66
66
  """
67
+ valid_ids_str: str | NotGiven = NOT_GIVEN
68
+ valid_tags_str: str | NotGiven = NOT_GIVEN
69
+
70
+ if isinstance(budget_ids, NotGiven):
71
+ valid_ids_str = NOT_GIVEN
72
+ else:
73
+ # Proceed with the list comprehension if budget_ids is not NotGiven
74
+ valid_ids = [id.strip() for id in budget_ids if id.strip()]
75
+ valid_ids_str = ",".join(valid_ids) if valid_ids else NOT_GIVEN
76
+ if isinstance(request_tags, NotGiven):
77
+ valid_tags_str = NOT_GIVEN
78
+ else:
79
+ # Proceed with the list comprehension if budget_ids is not NotGiven
80
+ valid_tags = [tag.strip() for tag in request_tags if tag.strip()]
81
+ valid_tags_str = ",".join(valid_tags) if valid_tags else NOT_GIVEN
82
+
67
83
  extra_headers = {
68
84
  **strip_not_given(
69
85
  {
70
- "xProxy-Budget-IDs": budget_ids,
71
- "xProxy-Request-Tags": request_tags,
86
+ "xProxy-Budget-IDs": valid_ids_str,
87
+ "xProxy-Request-Tags": valid_tags_str,
72
88
  }
73
89
  ),
74
90
  **(extra_headers or {}),
@@ -107,8 +123,8 @@ class AsyncIngestResource(AsyncAPIResource):
107
123
  input: int,
108
124
  output: int,
109
125
  resource: str,
110
- budget_ids: str | NotGiven = NOT_GIVEN,
111
- request_tags: str | NotGiven = NOT_GIVEN,
126
+ budget_ids: list[str] | NotGiven = NOT_GIVEN,
127
+ request_tags: list[str] | NotGiven = NOT_GIVEN,
112
128
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
113
129
  # The extra values given here take precedence over values defined on the client or passed to this method.
114
130
  extra_headers: Headers | None = None,
@@ -128,11 +144,27 @@ class AsyncIngestResource(AsyncAPIResource):
128
144
 
129
145
  timeout: Override the client-level default timeout for this request, in seconds
130
146
  """
147
+ valid_ids_str: str | NotGiven = NOT_GIVEN
148
+ valid_tags_str: str | NotGiven = NOT_GIVEN
149
+
150
+ if isinstance(budget_ids, NotGiven):
151
+ valid_ids_str = NOT_GIVEN
152
+ else:
153
+ # Proceed with the list comprehension if budget_ids is not NotGiven
154
+ valid_ids = [id.strip() for id in budget_ids if id.strip()]
155
+ valid_ids_str = ",".join(valid_ids) if valid_ids else NOT_GIVEN
156
+ if isinstance(request_tags, NotGiven):
157
+ valid_tags_str = NOT_GIVEN
158
+ else:
159
+ # Proceed with the list comprehension if budget_ids is not NotGiven
160
+ valid_tags = [tag.strip() for tag in request_tags if tag.strip()]
161
+ valid_tags_str = ",".join(valid_tags) if valid_tags else NOT_GIVEN
162
+
131
163
  extra_headers = {
132
164
  **strip_not_given(
133
165
  {
134
- "xProxy-Budget-IDs": budget_ids,
135
- "xProxy-Request-Tags": request_tags,
166
+ "xProxy-Budget-IDs": valid_ids_str,
167
+ "xProxy-Request-Tags": valid_tags_str,
136
168
  }
137
169
  ),
138
170
  **(extra_headers or {}),
@@ -18,6 +18,6 @@ class IngestUnitsParams(TypedDict, total=False):
18
18
 
19
19
  resource: Required[str]
20
20
 
21
- budget_ids: Annotated[str, PropertyInfo(alias="xProxy-Budget-IDs")]
21
+ budget_ids: Annotated[list[str], PropertyInfo(alias="xProxy-Budget-IDs")]
22
22
 
23
- request_tags: Annotated[str, PropertyInfo(alias="xProxy-Request-Tags")]
23
+ request_tags: Annotated[list[str], PropertyInfo(alias="xProxy-Request-Tags")]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: payi
3
- Version: 0.1.0a4
3
+ Version: 0.1.0a6
4
4
  Summary: The official Python library for the payi API
5
5
  Project-URL: Homepage, https://github.com/Pay-i/pay-i-python
6
6
  Project-URL: Repository, https://github.com/Pay-i/pay-i-python
@@ -11,20 +11,21 @@ payi/_resource.py,sha256=j2jIkTr8OIC8sU6-05nxSaCyj4MaFlbZrwlyg4_xJos,1088
11
11
  payi/_response.py,sha256=W6pADUzbnMFGnVzGY4M3FkX9uvw8AFSMTPZKPgQ_TV4,28363
12
12
  payi/_streaming.py,sha256=Z_wIyo206T6Jqh2rolFg2VXZgX24PahLmpURp0-NssU,10092
13
13
  payi/_types.py,sha256=04q-KHD-qZ1xlfwEb_muyIHWmD-nZ-KxnRxA_QEjqNk,6125
14
- payi/_version.py,sha256=JnOWhSSjvRoW9IyOBb60KZeTaqp-L3yZnbSNJszRL1I,164
14
+ payi/_version.py,sha256=uCFQ98dFvMtHydofeML_9k-XyAQblroEZWJv-OZ3N6g,164
15
15
  payi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- payi/_utils/__init__.py,sha256=q5QC6ZmVNli9QaCqTlp9VrbQyjIU9EzmCn044UhHSIk,1919
16
+ payi/_utils/__init__.py,sha256=Uzq1-FIih_VUjzdNVWXks0sdC39KBKLMrZoz-_JOjJ4,1988
17
17
  payi/_utils/_logs.py,sha256=fmnf5D9TOgkgZKfgYmSa3PiUc3SZgkchn6CzJUeo0SQ,768
18
18
  payi/_utils/_proxy.py,sha256=DjcB-BBIRagSbMut2pF_jZavjda9sPvmQCKtVXBhs0I,1910
19
- payi/_utils/_reflection.py,sha256=Xloc_oanCC3gmAVBRhlMYtvYeLNZGi46gGWhDt9FtKI,275
19
+ payi/_utils/_reflection.py,sha256=k20KwLejVHcQCvu4mT2S61NDvbmuXF7KsMDapiocYS0,1364
20
20
  payi/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
21
21
  payi/_utils/_sync.py,sha256=9ex9pfOyd8xAF1LxpFx4IkqL8k0vk8srE2Ee-OTMQ0A,2840
22
22
  payi/_utils/_transform.py,sha256=NCz3q9_O-vuj60xVe-qzhEQ8uJWlZWJTsM-GwHDccf8,12958
23
23
  payi/_utils/_typing.py,sha256=tFbktdpdHCQliwzGsWysgn0P5H0JRdagkZdb_LegGkY,3838
24
24
  payi/_utils/_utils.py,sha256=FaZdW0tWil7IERdxUfKt7pVcyXL2aCnR3lo73q66qgI,11447
25
25
  payi/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
26
+ payi/lib/helpers.py,sha256=IdB_pi8dLtVh9b4DG-zasA1i9Yk-5xAayoUTNWBAFpc,1235
26
27
  payi/resources/__init__.py,sha256=1p8kzMES8NNDQQoK3TEDE-8vVuQ59xxUjyyblZJBTjw,1015
27
- payi/resources/ingest.py,sha256=xecLJfQ3n5SOFSY4rYKkj-4A8w5vBEcH0fTB6CCcRqY,6128
28
+ payi/resources/ingest.py,sha256=IByW243qermlbqhlTYB_ZjhJ7Jfck6OREVJWsn2vATc,7692
28
29
  payi/resources/budgets/__init__.py,sha256=w1UhOdDXtUH4A91ME5Tw2nr9bRvPJyJY1YWiVVy7jj0,989
29
30
  payi/resources/budgets/budgets.py,sha256=aMu39MrRsVTtNfYwQPMeFK329ouwnHuFXM_vK9Ewj0k,24047
30
31
  payi/resources/budgets/tags.py,sha256=jzP0nal287bL2htY1TwDcdFRJyNMm6IdM936O1jCeMo,17850
@@ -35,7 +36,7 @@ payi/types/budget_list_params.py,sha256=Win-Spveurf6WarTgCXXsP-yDIxr_HCP7oV_4Jbq
35
36
  payi/types/budget_response.py,sha256=yXDXIrespfRuNreWdWmlCITO6VvLC4YZn0nzXw_BGzo,2072
36
37
  payi/types/budget_update_params.py,sha256=TTH7uu1c1zBK5zYhh2SPuRWEwr1XwDX_8bVS_GxIn9I,306
37
38
  payi/types/default_response.py,sha256=o617LpRsCIZHCZxAc5nVI2JQ3HPGZo4gCDvSDkxkIJ8,270
38
- payi/types/ingest_units_params.py,sha256=SLe9mE2N28b3H61gIOGalfHogD9grBFv3WsHQnImS58,563
39
+ payi/types/ingest_units_params.py,sha256=NhC7wRF0lpoKikUPQUAgE1OxpU8dqMxtRZNIbiXkYCA,575
39
40
  payi/types/paged_budget_list.py,sha256=HNm834IAAy3eRNz0BjZwcbD9e-I8unWWKWxiSnlijWY,2553
40
41
  payi/types/successful_proxy_result.py,sha256=j8kQu8LAcfR3XuforqWDsYm1Bx6BQxCrezmE-3GnCWc,893
41
42
  payi/types/budgets/__init__.py,sha256=8lpRHXZQOc9ADCphhCB0JhQAH96lBIc68LbhlJn5Kys,750
@@ -48,7 +49,7 @@ payi/types/budgets/tag_remove_params.py,sha256=fNiHex1U11o_B0bfJDkpGARkEf99J-bd-
48
49
  payi/types/budgets/tag_remove_response.py,sha256=Gc_eBGGSx6Afa51g-S5AkXqwmRcGMjshiNSBsthDZJc,244
49
50
  payi/types/budgets/tag_update_params.py,sha256=bWWeDqfySt7CZ6HDsZzENREOWGWGWFgnAtyleNMwUsE,314
50
51
  payi/types/budgets/tag_update_response.py,sha256=5Q16vkLUMLkyzgCWRcz7aDVA0KTCHQd_eAKnx2-VoWQ,244
51
- payi-0.1.0a4.dist-info/METADATA,sha256=0oNFDUKAjdE7jU3cM4WKqGBrEVVVMR6HINTIQ8Hp91c,11872
52
- payi-0.1.0a4.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
53
- payi-0.1.0a4.dist-info/licenses/LICENSE,sha256=8vX1pjh3esb6D5DvXAf6NxiBcVyon8aHWNJCxmmHXeY,11334
54
- payi-0.1.0a4.dist-info/RECORD,,
52
+ payi-0.1.0a6.dist-info/METADATA,sha256=FGdRSVefjz5gmzywelk9u4MR60cFlIHDWrSUCUA5wPM,11872
53
+ payi-0.1.0a6.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
54
+ payi-0.1.0a6.dist-info/licenses/LICENSE,sha256=8vX1pjh3esb6D5DvXAf6NxiBcVyon8aHWNJCxmmHXeY,11334
55
+ payi-0.1.0a6.dist-info/RECORD,,
File without changes