payi 0.1.0a29__py3-none-any.whl → 0.1.0a30__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/_base_client.py CHANGED
@@ -792,6 +792,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
792
792
  custom_query: Mapping[str, object] | None = None,
793
793
  _strict_response_validation: bool,
794
794
  ) -> None:
795
+ kwargs: dict[str, Any] = {}
795
796
  if limits is not None:
796
797
  warnings.warn(
797
798
  "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
@@ -804,6 +805,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
804
805
  limits = DEFAULT_CONNECTION_LIMITS
805
806
 
806
807
  if transport is not None:
808
+ kwargs["transport"] = transport
807
809
  warnings.warn(
808
810
  "The `transport` argument is deprecated. The `http_client` argument should be passed instead",
809
811
  category=DeprecationWarning,
@@ -813,6 +815,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
813
815
  raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
814
816
 
815
817
  if proxies is not None:
818
+ kwargs["proxies"] = proxies
816
819
  warnings.warn(
817
820
  "The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
818
821
  category=DeprecationWarning,
@@ -856,10 +859,9 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
856
859
  base_url=base_url,
857
860
  # cast to a valid type because mypy doesn't understand our type narrowing
858
861
  timeout=cast(Timeout, timeout),
859
- proxies=proxies,
860
- transport=transport,
861
862
  limits=limits,
862
863
  follow_redirects=True,
864
+ **kwargs, # type: ignore
863
865
  )
864
866
 
865
867
  def is_closed(self) -> bool:
@@ -1358,6 +1360,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1358
1360
  custom_headers: Mapping[str, str] | None = None,
1359
1361
  custom_query: Mapping[str, object] | None = None,
1360
1362
  ) -> None:
1363
+ kwargs: dict[str, Any] = {}
1361
1364
  if limits is not None:
1362
1365
  warnings.warn(
1363
1366
  "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
@@ -1370,6 +1373,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1370
1373
  limits = DEFAULT_CONNECTION_LIMITS
1371
1374
 
1372
1375
  if transport is not None:
1376
+ kwargs["transport"] = transport
1373
1377
  warnings.warn(
1374
1378
  "The `transport` argument is deprecated. The `http_client` argument should be passed instead",
1375
1379
  category=DeprecationWarning,
@@ -1379,6 +1383,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1379
1383
  raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
1380
1384
 
1381
1385
  if proxies is not None:
1386
+ kwargs["proxies"] = proxies
1382
1387
  warnings.warn(
1383
1388
  "The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
1384
1389
  category=DeprecationWarning,
@@ -1422,10 +1427,9 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1422
1427
  base_url=base_url,
1423
1428
  # cast to a valid type because mypy doesn't understand our type narrowing
1424
1429
  timeout=cast(Timeout, timeout),
1425
- proxies=proxies,
1426
- transport=transport,
1427
1430
  limits=limits,
1428
1431
  follow_redirects=True,
1432
+ **kwargs, # type: ignore
1429
1433
  )
1430
1434
 
1431
1435
  def is_closed(self) -> bool:
payi/_compat.py CHANGED
@@ -145,7 +145,8 @@ def model_dump(
145
145
  exclude=exclude,
146
146
  exclude_unset=exclude_unset,
147
147
  exclude_defaults=exclude_defaults,
148
- warnings=warnings,
148
+ # warnings are not supported in Pydantic v1
149
+ warnings=warnings if PYDANTIC_V2 else True,
149
150
  )
150
151
  return cast(
151
152
  "dict[str, Any]",
@@ -213,9 +214,6 @@ if TYPE_CHECKING:
213
214
  # __set__ is not defined at runtime, but @cached_property is designed to be settable
214
215
  def __set__(self, instance: object, value: _T) -> None: ...
215
216
  else:
216
- try:
217
- from functools import cached_property as cached_property
218
- except ImportError:
219
- from cached_property import cached_property as cached_property
217
+ from functools import cached_property as cached_property
220
218
 
221
219
  typed_cached_property = cached_property
payi/_utils/_sync.py CHANGED
@@ -1,56 +1,62 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import sys
4
+ import asyncio
3
5
  import functools
4
- from typing import TypeVar, Callable, Awaitable
6
+ import contextvars
7
+ from typing import Any, TypeVar, Callable, Awaitable
5
8
  from typing_extensions import ParamSpec
6
9
 
7
- import anyio
8
- import anyio.to_thread
9
-
10
- from ._reflection import function_has_argument
11
-
12
10
  T_Retval = TypeVar("T_Retval")
13
11
  T_ParamSpec = ParamSpec("T_ParamSpec")
14
12
 
15
13
 
16
- # copied from `asyncer`, https://github.com/tiangolo/asyncer
17
- def asyncify(
18
- function: Callable[T_ParamSpec, T_Retval],
19
- *,
20
- cancellable: bool = False,
21
- limiter: anyio.CapacityLimiter | None = None,
22
- ) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
14
+ if sys.version_info >= (3, 9):
15
+ to_thread = asyncio.to_thread
16
+ else:
17
+ # backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
18
+ # for Python 3.8 support
19
+ async def to_thread(
20
+ func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
21
+ ) -> Any:
22
+ """Asynchronously run function *func* in a separate thread.
23
+
24
+ Any *args and **kwargs supplied for this function are directly passed
25
+ to *func*. Also, the current :class:`contextvars.Context` is propagated,
26
+ allowing context variables from the main thread to be accessed in the
27
+ separate thread.
28
+
29
+ Returns a coroutine that can be awaited to get the eventual result of *func*.
30
+ """
31
+ loop = asyncio.events.get_running_loop()
32
+ ctx = contextvars.copy_context()
33
+ func_call = functools.partial(ctx.run, func, *args, **kwargs)
34
+ return await loop.run_in_executor(None, func_call)
35
+
36
+
37
+ # inspired by `asyncer`, https://github.com/tiangolo/asyncer
38
+ def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
23
39
  """
24
40
  Take a blocking function and create an async one that receives the same
25
- positional and keyword arguments, and that when called, calls the original function
26
- in a worker thread using `anyio.to_thread.run_sync()`. Internally,
27
- `asyncer.asyncify()` uses the same `anyio.to_thread.run_sync()`, but it supports
28
- keyword arguments additional to positional arguments and it adds better support for
29
- autocompletion and inline errors for the arguments of the function called and the
30
- return value.
31
-
32
- If the `cancellable` option is enabled and the task waiting for its completion is
33
- cancelled, the thread will still run its course but its return value (or any raised
34
- exception) will be ignored.
41
+ positional and keyword arguments. For python version 3.9 and above, it uses
42
+ asyncio.to_thread to run the function in a separate thread. For python version
43
+ 3.8, it uses locally defined copy of the asyncio.to_thread function which was
44
+ introduced in python 3.9.
35
45
 
36
- Use it like this:
46
+ Usage:
37
47
 
38
- ```Python
39
- def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str:
40
- # Do work
41
- return "Some result"
48
+ ```python
49
+ def blocking_func(arg1, arg2, kwarg1=None):
50
+ # blocking code
51
+ return result
42
52
 
43
53
 
44
- result = await to_thread.asyncify(do_work)("spam", "ham", kwarg1="a", kwarg2="b")
45
- print(result)
54
+ result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
46
55
  ```
47
56
 
48
57
  ## Arguments
49
58
 
50
59
  `function`: a blocking regular callable (e.g. a function)
51
- `cancellable`: `True` to allow cancellation of the operation
52
- `limiter`: capacity limiter to use to limit the total amount of threads running
53
- (if omitted, the default limiter is used)
54
60
 
55
61
  ## Return
56
62
 
@@ -60,22 +66,6 @@ def asyncify(
60
66
  """
61
67
 
62
68
  async def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval:
63
- partial_f = functools.partial(function, *args, **kwargs)
64
-
65
- # In `v4.1.0` anyio added the `abandon_on_cancel` argument and deprecated the old
66
- # `cancellable` argument, so we need to use the new `abandon_on_cancel` to avoid
67
- # surfacing deprecation warnings.
68
- if function_has_argument(anyio.to_thread.run_sync, "abandon_on_cancel"):
69
- return await anyio.to_thread.run_sync(
70
- partial_f,
71
- abandon_on_cancel=cancellable,
72
- limiter=limiter,
73
- )
74
-
75
- return await anyio.to_thread.run_sync(
76
- partial_f,
77
- cancellable=cancellable,
78
- limiter=limiter,
79
- )
69
+ return await to_thread(function, *args, **kwargs)
80
70
 
81
71
  return wrapper
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.29" # x-release-please-version
4
+ __version__ = "0.1.0-alpha.30" # x-release-please-version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: payi
3
- Version: 0.1.0a29
3
+ Version: 0.1.0a30
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
@@ -22,7 +22,6 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
22
  Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.8
24
24
  Requires-Dist: anyio<5,>=3.5.0
25
- Requires-Dist: cached-property; python_version < '3.8'
26
25
  Requires-Dist: distro<2,>=1.7.0
27
26
  Requires-Dist: httpx<1,>=0.23.0
28
27
  Requires-Dist: pydantic<3,>=1.9.0
@@ -215,12 +214,14 @@ Note that requests that time out are [retried twice by default](https://github.c
215
214
 
216
215
  We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
217
216
 
218
- You can enable logging by setting the environment variable `PAYI_LOG` to `debug`.
217
+ You can enable logging by setting the environment variable `PAYI_LOG` to `info`.
219
218
 
220
219
  ```shell
221
- $ export PAYI_LOG=debug
220
+ $ export PAYI_LOG=info
222
221
  ```
223
222
 
223
+ Or to `debug` for more verbose logging.
224
+
224
225
  ### How to tell whether `None` means `null` or missing
225
226
 
226
227
  In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
@@ -1,7 +1,7 @@
1
1
  payi/__init__.py,sha256=LWpfR6WSMPTnmmx3ToqqZ0A8CNduLcuxY1SSOqhPxuk,2381
2
- payi/_base_client.py,sha256=Jq9mZjEknHo-6ZANRPCQXVHTbbC4Hh7QLFv2jrNtGJ0,67842
2
+ payi/_base_client.py,sha256=s3JMTpYuiwtp-jn6iB79v4iuCc29C1Rr38el1IXMtHs,68034
3
3
  payi/_client.py,sha256=ZB23I50J5Ia4etp6zoB7pfFf1XgWXeAL0PMq2UOPlbI,18474
4
- payi/_compat.py,sha256=fQkXUY7reJc8m_yguMWSjHBfO8lNzw4wOAxtkhP9d1Q,6607
4
+ payi/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
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
@@ -11,14 +11,14 @@ 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
13
  payi/_types.py,sha256=J0i_n21O_stX9WmxhCAuKnzv4oJgEPGykFNVqcXg0d0,6165
14
- payi/_version.py,sha256=LjV6CHhZAn2UT95fYR0p4FqYZhbby0Y-U5hNhP2zKUU,165
14
+ payi/_version.py,sha256=gUOFAFR06FRMqmxyJIsv_ieAzDCrplWGCTr7mY_0dHQ,165
15
15
  payi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
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
- payi/_utils/_sync.py,sha256=9ex9pfOyd8xAF1LxpFx4IkqL8k0vk8srE2Ee-OTMQ0A,2840
21
+ payi/_utils/_sync.py,sha256=jJl-iCEaZZUAkq4IUtzN1-aMsKTUFaNoNbeYnnpQjIQ,2438
22
22
  payi/_utils/_transform.py,sha256=Dkkyr7OveGmOolepcvXmVJWE3kqim4b0nM0h7yWbgeY,13468
23
23
  payi/_utils/_typing.py,sha256=tFbktdpdHCQliwzGsWysgn0P5H0JRdagkZdb_LegGkY,3838
24
24
  payi/_utils/_utils.py,sha256=8UmbPOy_AAr2uUjjFui-VZSrVBHRj6bfNEKRp5YZP2A,12004
@@ -91,7 +91,7 @@ payi/types/experiences/type_create_params.py,sha256=56vS9kTHex1eU9QQ-DWjBMqoHNhO
91
91
  payi/types/experiences/type_list_params.py,sha256=VDZjHmK2tNAW_YLewcIzM-OG13iI2v-xCykokxkcgbs,286
92
92
  payi/types/experiences/type_list_response.py,sha256=DgkPLw40oUqBETLePVMVenstMsGG12rZRU9w6kgQN28,280
93
93
  payi/types/experiences/type_update_params.py,sha256=izwlElQB-jeFFX3K6S2TqVUMmhU0KTmwScQ5aoHZH0M,361
94
- payi-0.1.0a29.dist-info/METADATA,sha256=ml0Mzau3CmtZ7W5ZgmL5NX2IfxbTnLKSrM3EzTPfXX4,12358
95
- payi-0.1.0a29.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
96
- payi-0.1.0a29.dist-info/licenses/LICENSE,sha256=8vX1pjh3esb6D5DvXAf6NxiBcVyon8aHWNJCxmmHXeY,11334
97
- payi-0.1.0a29.dist-info/RECORD,,
94
+ payi-0.1.0a30.dist-info/METADATA,sha256=mCnbSpQ48ks_6_G-0g77SecB2gro8jAm4flz9bDp2LM,12342
95
+ payi-0.1.0a30.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
96
+ payi-0.1.0a30.dist-info/licenses/LICENSE,sha256=8vX1pjh3esb6D5DvXAf6NxiBcVyon8aHWNJCxmmHXeY,11334
97
+ payi-0.1.0a30.dist-info/RECORD,,