payi 0.1.0a27__py3-none-any.whl → 0.1.0a28__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/_compat.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
4
4
  from datetime import date, datetime
5
- from typing_extensions import Self
5
+ from typing_extensions import Self, Literal
6
6
 
7
7
  import pydantic
8
8
  from pydantic.fields import FieldInfo
@@ -133,13 +133,15 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
133
133
  def model_dump(
134
134
  model: pydantic.BaseModel,
135
135
  *,
136
- exclude: IncEx = None,
136
+ exclude: IncEx | None = None,
137
137
  exclude_unset: bool = False,
138
138
  exclude_defaults: bool = False,
139
139
  warnings: bool = True,
140
+ mode: Literal["json", "python"] = "python",
140
141
  ) -> dict[str, Any]:
141
- if PYDANTIC_V2:
142
+ if PYDANTIC_V2 or hasattr(model, "model_dump"):
142
143
  return model.model_dump(
144
+ mode=mode,
143
145
  exclude=exclude,
144
146
  exclude_unset=exclude_unset,
145
147
  exclude_defaults=exclude_defaults,
payi/_models.py CHANGED
@@ -37,6 +37,7 @@ from ._utils import (
37
37
  PropertyInfo,
38
38
  is_list,
39
39
  is_given,
40
+ json_safe,
40
41
  lru_cache,
41
42
  is_mapping,
42
43
  parse_date,
@@ -176,7 +177,7 @@ class BaseModel(pydantic.BaseModel):
176
177
  # Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
177
178
  @classmethod
178
179
  @override
179
- def construct(
180
+ def construct( # pyright: ignore[reportIncompatibleMethodOverride]
180
181
  cls: Type[ModelT],
181
182
  _fields_set: set[str] | None = None,
182
183
  **values: object,
@@ -248,8 +249,8 @@ class BaseModel(pydantic.BaseModel):
248
249
  self,
249
250
  *,
250
251
  mode: Literal["json", "python"] | str = "python",
251
- include: IncEx = None,
252
- exclude: IncEx = None,
252
+ include: IncEx | None = None,
253
+ exclude: IncEx | None = None,
253
254
  by_alias: bool = False,
254
255
  exclude_unset: bool = False,
255
256
  exclude_defaults: bool = False,
@@ -279,8 +280,8 @@ class BaseModel(pydantic.BaseModel):
279
280
  Returns:
280
281
  A dictionary representation of the model.
281
282
  """
282
- if mode != "python":
283
- raise ValueError("mode is only supported in Pydantic v2")
283
+ if mode not in {"json", "python"}:
284
+ raise ValueError("mode must be either 'json' or 'python'")
284
285
  if round_trip != False:
285
286
  raise ValueError("round_trip is only supported in Pydantic v2")
286
287
  if warnings != True:
@@ -289,7 +290,7 @@ class BaseModel(pydantic.BaseModel):
289
290
  raise ValueError("context is only supported in Pydantic v2")
290
291
  if serialize_as_any != False:
291
292
  raise ValueError("serialize_as_any is only supported in Pydantic v2")
292
- return super().dict( # pyright: ignore[reportDeprecated]
293
+ dumped = super().dict( # pyright: ignore[reportDeprecated]
293
294
  include=include,
294
295
  exclude=exclude,
295
296
  by_alias=by_alias,
@@ -298,13 +299,15 @@ class BaseModel(pydantic.BaseModel):
298
299
  exclude_none=exclude_none,
299
300
  )
300
301
 
302
+ return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
303
+
301
304
  @override
302
305
  def model_dump_json(
303
306
  self,
304
307
  *,
305
308
  indent: int | None = None,
306
- include: IncEx = None,
307
- exclude: IncEx = None,
309
+ include: IncEx | None = None,
310
+ exclude: IncEx | None = None,
308
311
  by_alias: bool = False,
309
312
  exclude_unset: bool = False,
310
313
  exclude_defaults: bool = False,
payi/_types.py CHANGED
@@ -16,7 +16,7 @@ from typing import (
16
16
  Optional,
17
17
  Sequence,
18
18
  )
19
- from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
19
+ from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
20
20
 
21
21
  import httpx
22
22
  import pydantic
@@ -193,7 +193,9 @@ StrBytesIntFloat = Union[str, bytes, int, float]
193
193
 
194
194
  # Note: copied from Pydantic
195
195
  # https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49
196
- IncEx: TypeAlias = "set[int] | set[str] | dict[int, Any] | dict[str, Any] | None"
196
+ IncEx: TypeAlias = Union[
197
+ Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]]
198
+ ]
197
199
 
198
200
  PostParser = Callable[[Any], Any]
199
201
 
payi/_utils/__init__.py CHANGED
@@ -6,6 +6,7 @@ from ._utils import (
6
6
  is_list as is_list,
7
7
  is_given as is_given,
8
8
  is_tuple as is_tuple,
9
+ json_safe as json_safe,
9
10
  lru_cache as lru_cache,
10
11
  is_mapping as is_mapping,
11
12
  is_tuple_t as is_tuple_t,
payi/_utils/_transform.py CHANGED
@@ -173,6 +173,11 @@ def _transform_recursive(
173
173
  # Iterable[T]
174
174
  or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
175
175
  ):
176
+ # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
177
+ # intended as an iterable, so we don't transform it.
178
+ if isinstance(data, dict):
179
+ return cast(object, data)
180
+
176
181
  inner_type = extract_type_arg(stripped_type, 0)
177
182
  return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
178
183
 
@@ -186,7 +191,7 @@ def _transform_recursive(
186
191
  return data
187
192
 
188
193
  if isinstance(data, pydantic.BaseModel):
189
- return model_dump(data, exclude_unset=True)
194
+ return model_dump(data, exclude_unset=True, mode="json")
190
195
 
191
196
  annotated_type = _get_annotated_type(annotation)
192
197
  if annotated_type is None:
@@ -311,6 +316,11 @@ async def _async_transform_recursive(
311
316
  # Iterable[T]
312
317
  or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
313
318
  ):
319
+ # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
320
+ # intended as an iterable, so we don't transform it.
321
+ if isinstance(data, dict):
322
+ return cast(object, data)
323
+
314
324
  inner_type = extract_type_arg(stripped_type, 0)
315
325
  return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
316
326
 
@@ -324,7 +334,7 @@ async def _async_transform_recursive(
324
334
  return data
325
335
 
326
336
  if isinstance(data, pydantic.BaseModel):
327
- return model_dump(data, exclude_unset=True)
337
+ return model_dump(data, exclude_unset=True, mode="json")
328
338
 
329
339
  annotated_type = _get_annotated_type(annotation)
330
340
  if annotated_type is None:
payi/_utils/_utils.py CHANGED
@@ -16,6 +16,7 @@ from typing import (
16
16
  overload,
17
17
  )
18
18
  from pathlib import Path
19
+ from datetime import date, datetime
19
20
  from typing_extensions import TypeGuard
20
21
 
21
22
  import sniffio
@@ -395,3 +396,19 @@ def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
395
396
  maxsize=maxsize,
396
397
  )
397
398
  return cast(Any, wrapper) # type: ignore[no-any-return]
399
+
400
+
401
+ def json_safe(data: object) -> object:
402
+ """Translates a mapping / sequence recursively in the same fashion
403
+ as `pydantic` v2's `model_dump(mode="json")`.
404
+ """
405
+ if is_mapping(data):
406
+ return {json_safe(key): json_safe(value) for key, value in data.items()}
407
+
408
+ if is_iterable(data) and not isinstance(data, (str, bytes, bytearray)):
409
+ return [json_safe(item) for item in data]
410
+
411
+ if isinstance(data, (datetime, date)):
412
+ return data.isoformat()
413
+
414
+ return data
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.27" # x-release-please-version
4
+ __version__ = "0.1.0-alpha.28" # x-release-please-version
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: payi
3
- Version: 0.1.0a27
3
+ Version: 0.1.0a28
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
7
7
  Author-email: Payi <support@payi.com>
8
- License-Expression: Apache-2.0
9
- License-File: LICENSE
8
+ License: Apache-2.0
10
9
  Classifier: Intended Audience :: Developers
11
10
  Classifier: License :: OSI Approved :: Apache Software License
12
11
  Classifier: Operating System :: MacOS
@@ -14,7 +13,6 @@ Classifier: Operating System :: Microsoft :: Windows
14
13
  Classifier: Operating System :: OS Independent
15
14
  Classifier: Operating System :: POSIX
16
15
  Classifier: Operating System :: POSIX :: Linux
17
- Classifier: Programming Language :: Python :: 3.7
18
16
  Classifier: Programming Language :: Python :: 3.8
19
17
  Classifier: Programming Language :: Python :: 3.9
20
18
  Classifier: Programming Language :: Python :: 3.10
@@ -22,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.11
22
20
  Classifier: Programming Language :: Python :: 3.12
23
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
22
  Classifier: Typing :: Typed
25
- Requires-Python: >=3.7
23
+ Requires-Python: >=3.8
26
24
  Requires-Dist: anyio<5,>=3.5.0
27
25
  Requires-Dist: cached-property; python_version < '3.8'
28
26
  Requires-Dist: distro<2,>=1.7.0
@@ -36,7 +34,7 @@ Description-Content-Type: text/markdown
36
34
 
37
35
  [![PyPI version](https://img.shields.io/pypi/v/payi.svg)](https://pypi.org/project/payi/)
38
36
 
39
- The Payi Python library provides convenient access to the Payi REST API from any Python 3.7+
37
+ The Payi Python library provides convenient access to the Payi REST API from any Python 3.8+
40
38
  application. The library includes type definitions for all request params and response fields,
41
39
  and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
42
40
 
@@ -62,8 +60,7 @@ import os
62
60
  from payi import Payi
63
61
 
64
62
  client = Payi(
65
- # This is the default and can be omitted
66
- api_key=os.environ.get("PAYI_API_KEY"),
63
+ api_key=os.environ.get("PAYI_API_KEY"), # This is the default and can be omitted
67
64
  )
68
65
 
69
66
  budget_response = client.budgets.create(
@@ -88,8 +85,7 @@ import asyncio
88
85
  from payi import AsyncPayi
89
86
 
90
87
  client = AsyncPayi(
91
- # This is the default and can be omitted
92
- api_key=os.environ.get("PAYI_API_KEY"),
88
+ api_key=os.environ.get("PAYI_API_KEY"), # This is the default and can be omitted
93
89
  )
94
90
 
95
91
 
@@ -369,7 +365,7 @@ print(payi.__version__)
369
365
 
370
366
  ## Requirements
371
367
 
372
- Python 3.7 or higher.
368
+ Python 3.8 or higher.
373
369
 
374
370
  ## Contributing
375
371
 
@@ -1,27 +1,27 @@
1
1
  payi/__init__.py,sha256=LWpfR6WSMPTnmmx3ToqqZ0A8CNduLcuxY1SSOqhPxuk,2381
2
2
  payi/_base_client.py,sha256=Jq9mZjEknHo-6ZANRPCQXVHTbbC4Hh7QLFv2jrNtGJ0,67842
3
3
  payi/_client.py,sha256=ljPrM5gfpC2WHYmifPcdLIedJUuKD91GWcS49c3RE38,18472
4
- payi/_compat.py,sha256=9CWnEaYK0kot7aSNW-m2W9xZb5giIdvKN9sWxvBbbSA,6488
4
+ payi/_compat.py,sha256=fQkXUY7reJc8m_yguMWSjHBfO8lNzw4wOAxtkhP9d1Q,6607
5
5
  payi/_constants.py,sha256=JE8kyZa2Q4NK_i4fO--8siEYTzeHnT0fYbOFDgDP4uk,464
6
6
  payi/_exceptions.py,sha256=ItygKNrNXIVY0H6LsGVZvFuAHB3Vtm_VZXmWzCnpHy0,3216
7
7
  payi/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
8
- payi/_models.py,sha256=pXirq94yiihFXBbiR50vA-0NIlDurxbJ_rLXK062vWQ,28267
8
+ payi/_models.py,sha256=uhxvXZC0JO7HuGR_GWXH-zYKuptF2rwiGVJfMMfg3fw,28470
9
9
  payi/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
10
10
  payi/_resource.py,sha256=j2jIkTr8OIC8sU6-05nxSaCyj4MaFlbZrwlyg4_xJos,1088
11
11
  payi/_response.py,sha256=9ZpP3Agz-3ReY0RSJo7O7BAwD0UluwRsTSvljdTh1dg,28597
12
12
  payi/_streaming.py,sha256=Z_wIyo206T6Jqh2rolFg2VXZgX24PahLmpURp0-NssU,10092
13
- payi/_types.py,sha256=mb6zn5qmTK5j0QMh0fevdShT091HBL4w0YCUfQ3u5VY,6101
14
- payi/_version.py,sha256=hNxmK25K5CFd8y7EdjZnmmwT5sQZXdk3veswB1PvBOM,165
13
+ payi/_types.py,sha256=J0i_n21O_stX9WmxhCAuKnzv4oJgEPGykFNVqcXg0d0,6165
14
+ payi/_version.py,sha256=tJrJog9eov1GG_eNMMs92lHJsLovL1tr5BqqR7TaZvs,165
15
15
  payi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- payi/_utils/__init__.py,sha256=Uzq1-FIih_VUjzdNVWXks0sdC39KBKLMrZoz-_JOjJ4,1988
16
+ payi/_utils/__init__.py,sha256=k266EatJr88V8Zseb7xUimTlCeno9SynRfLwadHP1b4,2016
17
17
  payi/_utils/_logs.py,sha256=fmnf5D9TOgkgZKfgYmSa3PiUc3SZgkchn6CzJUeo0SQ,768
18
18
  payi/_utils/_proxy.py,sha256=z3zsateHtb0EARTWKk8QZNHfPkqJbqwd1lM993LBwGE,1902
19
19
  payi/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
20
20
  payi/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
21
21
  payi/_utils/_sync.py,sha256=9ex9pfOyd8xAF1LxpFx4IkqL8k0vk8srE2Ee-OTMQ0A,2840
22
- payi/_utils/_transform.py,sha256=NCz3q9_O-vuj60xVe-qzhEQ8uJWlZWJTsM-GwHDccf8,12958
22
+ payi/_utils/_transform.py,sha256=Dkkyr7OveGmOolepcvXmVJWE3kqim4b0nM0h7yWbgeY,13468
23
23
  payi/_utils/_typing.py,sha256=tFbktdpdHCQliwzGsWysgn0P5H0JRdagkZdb_LegGkY,3838
24
- payi/_utils/_utils.py,sha256=tYrr7IX-5NMwsVKbNggbzOM84uNw7XnAe06e2Ln8Or0,11472
24
+ payi/_utils/_utils.py,sha256=8UmbPOy_AAr2uUjjFui-VZSrVBHRj6bfNEKRp5YZP2A,12004
25
25
  payi/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
26
26
  payi/lib/helpers.py,sha256=JpI9vy--oJP5kUlcWK0yfyRUbIRMXkvLeUQC4g8rLNY,1472
27
27
  payi/resources/__init__.py,sha256=cnFr2LhHLYehosTS7idW9lW_CrDwFClh-Wpgp9uHxh0,3553
@@ -85,17 +85,13 @@ payi/types/budgets/tag_update_response.py,sha256=0L-0k2pGw9GndpwArjKhHwOOJgOTOTY
85
85
  payi/types/categories/__init__.py,sha256=HQScxfK3F_J9HYbphrhG6bYb7S6vtrwafLViar5pHcM,285
86
86
  payi/types/categories/resource_create_params.py,sha256=jEXNx_FvWA9D5170Gwf_YUcuAOaDq0RIGaGgPSEsheA,725
87
87
  payi/types/categories/resource_list_response.py,sha256=ODMelDlXvYcwxBsJwTX8miofywUY_JB0OvsFVCKJunU,320
88
- payi/types/evaluations/__init__.py,sha256=crWSnR2SwRTTp1nadR_i_dfpGCv4dTPuBh_sMoss0tQ,288
89
- payi/types/evaluations/experience_create_params.py,sha256=3leYJN4FHKJbTeym_uPlvX0vSqD8G8Lr8iPV8BwM5gw,353
90
- payi/types/evaluations/request_create_params.py,sha256=OPV7ff1fGgi6FbUzndN4j5omqFcCUaRzblHLxDsoQaI,347
91
88
  payi/types/experiences/__init__.py,sha256=8gAwTPOFwf87LFLyCwmDek2cIb2DHJYyI4Ymqoz6X1o,455
92
89
  payi/types/experiences/experience_type.py,sha256=UoFekiOnkBZ5kqIHcBa8YE9T7uxwp-gLp3QGgxAxOoc,243
93
90
  payi/types/experiences/type_create_params.py,sha256=8dNpffodzeD5vm3s6UJrZVOG7YsiTkXo7viDnoEoCZY,311
94
91
  payi/types/experiences/type_list_params.py,sha256=VDZjHmK2tNAW_YLewcIzM-OG13iI2v-xCykokxkcgbs,286
95
92
  payi/types/experiences/type_list_response.py,sha256=DgkPLw40oUqBETLePVMVenstMsGG12rZRU9w6kgQN28,280
96
93
  payi/types/experiences/type_update_params.py,sha256=SOHb1GQiHktLB6YtEzdPllDDowS3FCfQqVWSmf0pD8Q,286
97
- payi/types/shared/__init__.py,sha256=3y7YS-bs2g4eULmnsGcuBLsTZX1fg_05Ab5PdL1vEns,87
98
- payi-0.1.0a27.dist-info/METADATA,sha256=EREhH6xd4VVwlug7IPVFcF8ba4gwSPWdqGNAd0jat4I,12447
99
- payi-0.1.0a27.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
100
- payi-0.1.0a27.dist-info/licenses/LICENSE,sha256=8vX1pjh3esb6D5DvXAf6NxiBcVyon8aHWNJCxmmHXeY,11334
101
- payi-0.1.0a27.dist-info/RECORD,,
94
+ payi-0.1.0a28.dist-info/METADATA,sha256=5wiucLhuowVcjOnuF1ey5JVLjKwGt_b2G-YExHbhnZk,12358
95
+ payi-0.1.0a28.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
96
+ payi-0.1.0a28.dist-info/licenses/LICENSE,sha256=8vX1pjh3esb6D5DvXAf6NxiBcVyon8aHWNJCxmmHXeY,11334
97
+ payi-0.1.0a28.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,6 +0,0 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- from __future__ import annotations
4
-
5
- from .request_create_params import RequestCreateParams as RequestCreateParams
6
- from .experience_create_params import ExperienceCreateParams as ExperienceCreateParams
@@ -1,14 +0,0 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Optional
6
- from typing_extensions import Required, TypedDict
7
-
8
- __all__ = ["ExperienceCreateParams"]
9
-
10
-
11
- class ExperienceCreateParams(TypedDict, total=False):
12
- evaluation: Required[int]
13
-
14
- user_id: Optional[str]
@@ -1,14 +0,0 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Optional
6
- from typing_extensions import Required, TypedDict
7
-
8
- __all__ = ["RequestCreateParams"]
9
-
10
-
11
- class RequestCreateParams(TypedDict, total=False):
12
- evaluation: Required[int]
13
-
14
- user_id: Optional[str]
@@ -1,2 +0,0 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-