gmt-python-sdk 0.36.0__tar.gz → 0.37.0__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 (154) hide show
  1. gmt_python_sdk-0.37.0/.release-please-manifest.json +3 -0
  2. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/CHANGELOG.md +23 -0
  3. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/PKG-INFO +1 -1
  4. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/pyproject.toml +1 -1
  5. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_client.py +23 -1
  6. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_files.py +53 -3
  7. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_qs.py +2 -6
  8. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_types.py +3 -0
  9. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/__init__.py +0 -1
  10. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_utils.py +34 -23
  11. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_version.py +1 -1
  12. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_extract_files.py +23 -5
  13. gmt_python_sdk-0.37.0/tests/test_files.py +148 -0
  14. gmt_python_sdk-0.36.0/.release-please-manifest.json +0 -3
  15. gmt_python_sdk-0.36.0/tests/test_deepcopy.py +0 -58
  16. gmt_python_sdk-0.36.0/tests/test_files.py +0 -51
  17. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/.gitignore +0 -0
  18. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/CONTRIBUTING.md +0 -0
  19. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/LICENSE +0 -0
  20. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/README.md +0 -0
  21. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/SECURITY.md +0 -0
  22. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/api.md +0 -0
  23. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/bin/check-release-environment +0 -0
  24. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/bin/publish-pypi +0 -0
  25. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/examples/.keep +0 -0
  26. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/release-please-config.json +0 -0
  27. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/requirements-dev.lock +0 -0
  28. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/__init__.py +0 -0
  29. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_base_client.py +0 -0
  30. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_compat.py +0 -0
  31. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_constants.py +0 -0
  32. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_exceptions.py +0 -0
  33. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_models.py +0 -0
  34. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_resource.py +0 -0
  35. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_response.py +0 -0
  36. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_streaming.py +0 -0
  37. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_compat.py +0 -0
  38. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_datetime_parse.py +0 -0
  39. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_json.py +0 -0
  40. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_logs.py +0 -0
  41. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_path.py +0 -0
  42. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_proxy.py +0 -0
  43. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_reflection.py +0 -0
  44. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_resources_proxy.py +0 -0
  45. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_streams.py +0 -0
  46. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_sync.py +0 -0
  47. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_transform.py +0 -0
  48. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/_utils/_typing.py +0 -0
  49. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/lib/.keep +0 -0
  50. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/pagination.py +0 -0
  51. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/py.typed +0 -0
  52. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/__init__.py +0 -0
  53. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/accounts.py +0 -0
  54. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/__init__.py +0 -0
  55. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/discount.py +0 -0
  56. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/profile.py +0 -0
  57. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/referral/__init__.py +0 -0
  58. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/referral/referral.py +0 -0
  59. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/profile/referral/transaction.py +0 -0
  60. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/purchases/__init__.py +0 -0
  61. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/purchases/bulk.py +0 -0
  62. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/purchases/purchases.py +0 -0
  63. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/purchases_by_hash.py +0 -0
  64. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/service.py +0 -0
  65. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/telegram/__init__.py +0 -0
  66. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/telegram/purchases.py +0 -0
  67. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/telegram/telegram.py +0 -0
  68. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/resources/webhooks.py +0 -0
  69. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/__init__.py +0 -0
  70. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/account_list_countries_params.py +0 -0
  71. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/account_list_countries_response.py +0 -0
  72. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/account_list_params.py +0 -0
  73. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/account_list_response.py +0 -0
  74. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/account_retrieve_response.py +0 -0
  75. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/__init__.py +0 -0
  76. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/discount_retrieve_response.py +0 -0
  77. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral/__init__.py +0 -0
  78. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral/transaction_list_params.py +0 -0
  79. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral/transaction_list_response.py +0 -0
  80. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral_retrieve_response.py +0 -0
  81. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral_transfer_balance_params.py +0 -0
  82. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile/referral_transfer_balance_response.py +0 -0
  83. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_change_login_params.py +0 -0
  84. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_change_login_response.py +0 -0
  85. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_change_password_params.py +0 -0
  86. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_change_password_response.py +0 -0
  87. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_retrieve_response.py +0 -0
  88. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/profile_unbind_telegram_response.py +0 -0
  89. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_create_params.py +0 -0
  90. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_create_response.py +0 -0
  91. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_list_params.py +0 -0
  92. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_list_response.py +0 -0
  93. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_refund_response.py +0 -0
  94. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_request_verification_code_params.py +0 -0
  95. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_request_verification_code_response.py +0 -0
  96. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchase_retrieve_response.py +0 -0
  97. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/__init__.py +0 -0
  98. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/bulk_create_params.py +0 -0
  99. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/bulk_create_response.py +0 -0
  100. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases/bulk_retrieve_response.py +0 -0
  101. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases_by_hash_request_verification_code_params.py +0 -0
  102. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases_by_hash_request_verification_code_response.py +0 -0
  103. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/purchases_by_hash_retrieve_response.py +0 -0
  104. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/service_get_server_time_response.py +0 -0
  105. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/service_health_check_response.py +0 -0
  106. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/__init__.py +0 -0
  107. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_create_premium_params.py +0 -0
  108. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_create_premium_response.py +0 -0
  109. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_create_stars_params.py +0 -0
  110. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_create_stars_response.py +0 -0
  111. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_list_premium_params.py +0 -0
  112. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_list_premium_response.py +0 -0
  113. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_list_stars_params.py +0 -0
  114. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram/purchase_list_stars_response.py +0 -0
  115. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram_get_premium_price_params.py +0 -0
  116. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram_get_premium_price_response.py +0 -0
  117. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram_get_stars_price_params.py +0 -0
  118. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/telegram_get_stars_price_response.py +0 -0
  119. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/webhook_test_params.py +0 -0
  120. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/src/gmt/types/webhook_test_response.py +0 -0
  121. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/__init__.py +0 -0
  122. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/__init__.py +0 -0
  123. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/__init__.py +0 -0
  124. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/referral/__init__.py +0 -0
  125. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/referral/test_transaction.py +0 -0
  126. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/test_discount.py +0 -0
  127. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/profile/test_referral.py +0 -0
  128. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/purchases/__init__.py +0 -0
  129. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/purchases/test_bulk.py +0 -0
  130. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/telegram/__init__.py +0 -0
  131. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/telegram/test_purchases.py +0 -0
  132. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/test_accounts.py +0 -0
  133. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/test_profile.py +0 -0
  134. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/test_purchases.py +0 -0
  135. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/test_purchases_by_hash.py +0 -0
  136. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/test_service.py +0 -0
  137. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/test_telegram.py +0 -0
  138. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/api_resources/test_webhooks.py +0 -0
  139. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/conftest.py +0 -0
  140. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/sample_file.txt +0 -0
  141. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_client.py +0 -0
  142. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_models.py +0 -0
  143. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_qs.py +0 -0
  144. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_required_args.py +0 -0
  145. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_response.py +0 -0
  146. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_streaming.py +0 -0
  147. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_transform.py +0 -0
  148. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_utils/test_datetime_parse.py +0 -0
  149. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_utils/test_json.py +0 -0
  150. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_utils/test_path.py +0 -0
  151. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_utils/test_proxy.py +0 -0
  152. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/test_utils/test_typing.py +0 -0
  153. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/tests/utils.py +0 -0
  154. {gmt_python_sdk-0.36.0 → gmt_python_sdk-0.37.0}/uv.lock +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.37.0"
3
+ }
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.37.0 (2026-04-28)
4
+
5
+ Full Changelog: [v0.36.0...v0.37.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.36.0...v0.37.0)
6
+
7
+ ### Features
8
+
9
+ * support setting headers via env ([c55427d](https://github.com/cameo6/gmt-python-sdk/commit/c55427de52cb37445691ee9be890e94144394e3c))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * use correct field name format for multipart file arrays ([ddbca94](https://github.com/cameo6/gmt-python-sdk/commit/ddbca94beeb11a9012d71d216788d4906dd8880e))
15
+
16
+
17
+ ### Performance Improvements
18
+
19
+ * **client:** optimize file structure copying in multipart requests ([7a46aa1](https://github.com/cameo6/gmt-python-sdk/commit/7a46aa13908eb43a8f5d2d004a938ea604e22f4a))
20
+
21
+
22
+ ### Chores
23
+
24
+ * **internal:** more robust bootstrap script ([1248c86](https://github.com/cameo6/gmt-python-sdk/commit/1248c865522e5e041927e73fac626d2cb7acf234))
25
+
3
26
  ## 0.36.0 (2026-04-11)
4
27
 
5
28
  Full Changelog: [v0.35.1...v0.36.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.35.1...v0.36.0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: gmt-python-sdk
3
- Version: 0.36.0
3
+ Version: 0.37.0
4
4
  Summary: The official Python library for the gmt API
5
5
  Project-URL: Homepage, https://github.com/cameo6/gmt-python-sdk
6
6
  Project-URL: Repository, https://github.com/cameo6/gmt-python-sdk
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gmt-python-sdk"
3
- version = "0.36.0"
3
+ version = "0.37.0"
4
4
  description = "The official Python library for the gmt API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -19,7 +19,11 @@ from ._types import (
19
19
  RequestOptions,
20
20
  not_given,
21
21
  )
22
- from ._utils import is_given, get_async_library
22
+ from ._utils import (
23
+ is_given,
24
+ is_mapping_t,
25
+ get_async_library,
26
+ )
23
27
  from ._compat import cached_property
24
28
  from ._version import __version__
25
29
  from ._streaming import Stream as Stream, AsyncStream as AsyncStream
@@ -83,6 +87,15 @@ class Gmt(SyncAPIClient):
83
87
  if base_url is None:
84
88
  base_url = f"https://api.getmytg.com"
85
89
 
90
+ custom_headers_env = os.environ.get("GMT_CUSTOM_HEADERS")
91
+ if custom_headers_env is not None:
92
+ parsed: dict[str, str] = {}
93
+ for line in custom_headers_env.split("\n"):
94
+ colon = line.find(":")
95
+ if colon >= 0:
96
+ parsed[line[:colon].strip()] = line[colon + 1 :].strip()
97
+ default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
98
+
86
99
  super().__init__(
87
100
  version=__version__,
88
101
  base_url=base_url,
@@ -329,6 +342,15 @@ class AsyncGmt(AsyncAPIClient):
329
342
  if base_url is None:
330
343
  base_url = f"https://api.getmytg.com"
331
344
 
345
+ custom_headers_env = os.environ.get("GMT_CUSTOM_HEADERS")
346
+ if custom_headers_env is not None:
347
+ parsed: dict[str, str] = {}
348
+ for line in custom_headers_env.split("\n"):
349
+ colon = line.find(":")
350
+ if colon >= 0:
351
+ parsed[line[:colon].strip()] = line[colon + 1 :].strip()
352
+ default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
353
+
332
354
  super().__init__(
333
355
  version=__version__,
334
356
  base_url=base_url,
@@ -3,8 +3,8 @@ from __future__ import annotations
3
3
  import io
4
4
  import os
5
5
  import pathlib
6
- from typing import overload
7
- from typing_extensions import TypeGuard
6
+ from typing import Sequence, cast, overload
7
+ from typing_extensions import TypeVar, TypeGuard
8
8
 
9
9
  import anyio
10
10
 
@@ -17,7 +17,9 @@ from ._types import (
17
17
  HttpxFileContent,
18
18
  HttpxRequestFiles,
19
19
  )
20
- from ._utils import is_tuple_t, is_mapping_t, is_sequence_t
20
+ from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t
21
+
22
+ _T = TypeVar("_T")
21
23
 
22
24
 
23
25
  def is_base64_file_input(obj: object) -> TypeGuard[Base64FileInput]:
@@ -121,3 +123,51 @@ async def async_read_file_content(file: FileContent) -> HttpxFileContent:
121
123
  return await anyio.Path(file).read_bytes()
122
124
 
123
125
  return file
126
+
127
+
128
+ def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T:
129
+ """Copy only the containers along the given paths.
130
+
131
+ Used to guard against mutation by extract_files without copying the entire structure.
132
+ Only dicts and lists that lie on a path are copied; everything else
133
+ is returned by reference.
134
+
135
+ For example, given paths=[["foo", "files", "file"]] and the structure:
136
+ {
137
+ "foo": {
138
+ "bar": {"baz": {}},
139
+ "files": {"file": <content>}
140
+ }
141
+ }
142
+ The root dict, "foo", and "files" are copied (they lie on the path).
143
+ "bar" and "baz" are returned by reference (off the path).
144
+ """
145
+ return _deepcopy_with_paths(item, paths, 0)
146
+
147
+
148
+ def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T:
149
+ if not paths:
150
+ return item
151
+ if is_mapping(item):
152
+ key_to_paths: dict[str, list[Sequence[str]]] = {}
153
+ for path in paths:
154
+ if index < len(path):
155
+ key_to_paths.setdefault(path[index], []).append(path)
156
+
157
+ # if no path continues through this mapping, it won't be mutated and copying it is redundant
158
+ if not key_to_paths:
159
+ return item
160
+
161
+ result = dict(item)
162
+ for key, subpaths in key_to_paths.items():
163
+ if key in result:
164
+ result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1)
165
+ return cast(_T, result)
166
+ if is_list(item):
167
+ array_paths = [path for path in paths if index < len(path) and path[index] == "<array>"]
168
+
169
+ # if no path expects a list here, nothing will be mutated inside it - return by reference
170
+ if not array_paths:
171
+ return cast(_T, item)
172
+ return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item])
173
+ return item
@@ -2,17 +2,13 @@ from __future__ import annotations
2
2
 
3
3
  from typing import Any, List, Tuple, Union, Mapping, TypeVar
4
4
  from urllib.parse import parse_qs, urlencode
5
- from typing_extensions import Literal, get_args
5
+ from typing_extensions import get_args
6
6
 
7
- from ._types import NotGiven, not_given
7
+ from ._types import NotGiven, ArrayFormat, NestedFormat, not_given
8
8
  from ._utils import flatten
9
9
 
10
10
  _T = TypeVar("_T")
11
11
 
12
-
13
- ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
14
- NestedFormat = Literal["dots", "brackets"]
15
-
16
12
  PrimitiveData = Union[str, int, float, bool, None]
17
13
  # this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"]
18
14
  # https://github.com/microsoft/pyright/issues/3555
@@ -47,6 +47,9 @@ AnyMapping = Mapping[str, object]
47
47
  ModelT = TypeVar("ModelT", bound=pydantic.BaseModel)
48
48
  _T = TypeVar("_T")
49
49
 
50
+ ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
51
+ NestedFormat = Literal["dots", "brackets"]
52
+
50
53
 
51
54
  # Approximates httpx internal ProxiesTypes and RequestFiles types
52
55
  # while adding support for `PathLike` instances
@@ -24,7 +24,6 @@ from ._utils import (
24
24
  coerce_integer as coerce_integer,
25
25
  file_from_path as file_from_path,
26
26
  strip_not_given as strip_not_given,
27
- deepcopy_minimal as deepcopy_minimal,
28
27
  get_async_library as get_async_library,
29
28
  maybe_coerce_float as maybe_coerce_float,
30
29
  get_required_header as get_required_header,
@@ -17,11 +17,11 @@ from typing import (
17
17
  )
18
18
  from pathlib import Path
19
19
  from datetime import date, datetime
20
- from typing_extensions import TypeGuard
20
+ from typing_extensions import TypeGuard, get_args
21
21
 
22
22
  import sniffio
23
23
 
24
- from .._types import Omit, NotGiven, FileTypes, HeadersLike
24
+ from .._types import Omit, NotGiven, FileTypes, ArrayFormat, HeadersLike
25
25
 
26
26
  _T = TypeVar("_T")
27
27
  _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
@@ -40,25 +40,45 @@ def extract_files(
40
40
  query: Mapping[str, object],
41
41
  *,
42
42
  paths: Sequence[Sequence[str]],
43
+ array_format: ArrayFormat = "brackets",
43
44
  ) -> list[tuple[str, FileTypes]]:
44
45
  """Recursively extract files from the given dictionary based on specified paths.
45
46
 
46
47
  A path may look like this ['foo', 'files', '<array>', 'data'].
47
48
 
49
+ ``array_format`` controls how ``<array>`` segments contribute to the emitted
50
+ field name. Supported values: ``"brackets"`` (``foo[]``), ``"repeat"`` and
51
+ ``"comma"`` (``foo``), ``"indices"`` (``foo[0]``, ``foo[1]``).
52
+
48
53
  Note: this mutates the given dictionary.
49
54
  """
50
55
  files: list[tuple[str, FileTypes]] = []
51
56
  for path in paths:
52
- files.extend(_extract_items(query, path, index=0, flattened_key=None))
57
+ files.extend(_extract_items(query, path, index=0, flattened_key=None, array_format=array_format))
53
58
  return files
54
59
 
55
60
 
61
+ def _array_suffix(array_format: ArrayFormat, array_index: int) -> str:
62
+ if array_format == "brackets":
63
+ return "[]"
64
+ if array_format == "indices":
65
+ return f"[{array_index}]"
66
+ if array_format == "repeat" or array_format == "comma":
67
+ # Both repeat the bare field name for each file part; there is no
68
+ # meaningful way to comma-join binary parts.
69
+ return ""
70
+ raise NotImplementedError(
71
+ f"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}"
72
+ )
73
+
74
+
56
75
  def _extract_items(
57
76
  obj: object,
58
77
  path: Sequence[str],
59
78
  *,
60
79
  index: int,
61
80
  flattened_key: str | None,
81
+ array_format: ArrayFormat,
62
82
  ) -> list[tuple[str, FileTypes]]:
63
83
  try:
64
84
  key = path[index]
@@ -75,9 +95,11 @@ def _extract_items(
75
95
 
76
96
  if is_list(obj):
77
97
  files: list[tuple[str, FileTypes]] = []
78
- for entry in obj:
79
- assert_is_file_content(entry, key=flattened_key + "[]" if flattened_key else "")
80
- files.append((flattened_key + "[]", cast(FileTypes, entry)))
98
+ for array_index, entry in enumerate(obj):
99
+ suffix = _array_suffix(array_format, array_index)
100
+ emitted_key = (flattened_key + suffix) if flattened_key else suffix
101
+ assert_is_file_content(entry, key=emitted_key)
102
+ files.append((emitted_key, cast(FileTypes, entry)))
81
103
  return files
82
104
 
83
105
  assert_is_file_content(obj, key=flattened_key)
@@ -106,6 +128,7 @@ def _extract_items(
106
128
  path,
107
129
  index=index,
108
130
  flattened_key=flattened_key,
131
+ array_format=array_format,
109
132
  )
110
133
  elif is_list(obj):
111
134
  if key != "<array>":
@@ -117,9 +140,12 @@ def _extract_items(
117
140
  item,
118
141
  path,
119
142
  index=index,
120
- flattened_key=flattened_key + "[]" if flattened_key is not None else "[]",
143
+ flattened_key=(
144
+ (flattened_key if flattened_key is not None else "") + _array_suffix(array_format, array_index)
145
+ ),
146
+ array_format=array_format,
121
147
  )
122
- for item in obj
148
+ for array_index, item in enumerate(obj)
123
149
  ]
124
150
  )
125
151
 
@@ -177,21 +203,6 @@ def is_iterable(obj: object) -> TypeGuard[Iterable[object]]:
177
203
  return isinstance(obj, Iterable)
178
204
 
179
205
 
180
- def deepcopy_minimal(item: _T) -> _T:
181
- """Minimal reimplementation of copy.deepcopy() that will only copy certain object types:
182
-
183
- - mappings, e.g. `dict`
184
- - list
185
-
186
- This is done for performance reasons.
187
- """
188
- if is_mapping(item):
189
- return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
190
- if is_list(item):
191
- return cast(_T, [deepcopy_minimal(entry) for entry in item])
192
- return item
193
-
194
-
195
206
  # copied from https://github.com/Rapptz/RoboDanny
196
207
  def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str:
197
208
  size = len(seq)
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "gmt"
4
- __version__ = "0.36.0" # x-release-please-version
4
+ __version__ = "0.37.0" # x-release-please-version
@@ -4,7 +4,7 @@ from typing import Sequence
4
4
 
5
5
  import pytest
6
6
 
7
- from gmt._types import FileTypes
7
+ from gmt._types import FileTypes, ArrayFormat
8
8
  from gmt._utils import extract_files
9
9
 
10
10
 
@@ -37,10 +37,7 @@ def test_multiple_files() -> None:
37
37
 
38
38
  def test_top_level_file_array() -> None:
39
39
  query = {"files": [b"file one", b"file two"], "title": "hello"}
40
- assert extract_files(query, paths=[["files", "<array>"]]) == [
41
- ("files[]", b"file one"),
42
- ("files[]", b"file two"),
43
- ]
40
+ assert extract_files(query, paths=[["files", "<array>"]]) == [("files[]", b"file one"), ("files[]", b"file two")]
44
41
  assert query == {"title": "hello"}
45
42
 
46
43
 
@@ -71,3 +68,24 @@ def test_ignores_incorrect_paths(
71
68
  expected: list[tuple[str, FileTypes]],
72
69
  ) -> None:
73
70
  assert extract_files(query, paths=paths) == expected
71
+
72
+
73
+ @pytest.mark.parametrize(
74
+ "array_format,expected_top_level,expected_nested",
75
+ [
76
+ ("brackets", [("files[]", b"a"), ("files[]", b"b")], [("items[][file]", b"a"), ("items[][file]", b"b")]),
77
+ ("repeat", [("files", b"a"), ("files", b"b")], [("items[file]", b"a"), ("items[file]", b"b")]),
78
+ ("comma", [("files", b"a"), ("files", b"b")], [("items[file]", b"a"), ("items[file]", b"b")]),
79
+ ("indices", [("files[0]", b"a"), ("files[1]", b"b")], [("items[0][file]", b"a"), ("items[1][file]", b"b")]),
80
+ ],
81
+ )
82
+ def test_array_format_controls_file_field_names(
83
+ array_format: ArrayFormat,
84
+ expected_top_level: list[tuple[str, FileTypes]],
85
+ expected_nested: list[tuple[str, FileTypes]],
86
+ ) -> None:
87
+ top_level = {"files": [b"a", b"b"]}
88
+ assert extract_files(top_level, paths=[["files", "<array>"]], array_format=array_format) == expected_top_level
89
+
90
+ nested = {"items": [{"file": b"a"}, {"file": b"b"}]}
91
+ assert extract_files(nested, paths=[["items", "<array>", "file"]], array_format=array_format) == expected_nested
@@ -0,0 +1,148 @@
1
+ from pathlib import Path
2
+
3
+ import anyio
4
+ import pytest
5
+ from dirty_equals import IsDict, IsList, IsBytes, IsTuple
6
+
7
+ from gmt._files import to_httpx_files, deepcopy_with_paths, async_to_httpx_files
8
+ from gmt._utils import extract_files
9
+
10
+ readme_path = Path(__file__).parent.parent.joinpath("README.md")
11
+
12
+
13
+ def test_pathlib_includes_file_name() -> None:
14
+ result = to_httpx_files({"file": readme_path})
15
+ print(result)
16
+ assert result == IsDict({"file": IsTuple("README.md", IsBytes())})
17
+
18
+
19
+ def test_tuple_input() -> None:
20
+ result = to_httpx_files([("file", readme_path)])
21
+ print(result)
22
+ assert result == IsList(IsTuple("file", IsTuple("README.md", IsBytes())))
23
+
24
+
25
+ @pytest.mark.asyncio
26
+ async def test_async_pathlib_includes_file_name() -> None:
27
+ result = await async_to_httpx_files({"file": readme_path})
28
+ print(result)
29
+ assert result == IsDict({"file": IsTuple("README.md", IsBytes())})
30
+
31
+
32
+ @pytest.mark.asyncio
33
+ async def test_async_supports_anyio_path() -> None:
34
+ result = await async_to_httpx_files({"file": anyio.Path(readme_path)})
35
+ print(result)
36
+ assert result == IsDict({"file": IsTuple("README.md", IsBytes())})
37
+
38
+
39
+ @pytest.mark.asyncio
40
+ async def test_async_tuple_input() -> None:
41
+ result = await async_to_httpx_files([("file", readme_path)])
42
+ print(result)
43
+ assert result == IsList(IsTuple("file", IsTuple("README.md", IsBytes())))
44
+
45
+
46
+ def test_string_not_allowed() -> None:
47
+ with pytest.raises(TypeError, match="Expected file types input to be a FileContent type or to be a tuple"):
48
+ to_httpx_files(
49
+ {
50
+ "file": "foo", # type: ignore
51
+ }
52
+ )
53
+
54
+
55
+ def assert_different_identities(obj1: object, obj2: object) -> None:
56
+ assert obj1 == obj2
57
+ assert obj1 is not obj2
58
+
59
+
60
+ class TestDeepcopyWithPaths:
61
+ def test_copies_top_level_dict(self) -> None:
62
+ original = {"file": b"data", "other": "value"}
63
+ result = deepcopy_with_paths(original, [["file"]])
64
+ assert_different_identities(result, original)
65
+
66
+ def test_file_value_is_same_reference(self) -> None:
67
+ file_bytes = b"contents"
68
+ original = {"file": file_bytes}
69
+ result = deepcopy_with_paths(original, [["file"]])
70
+ assert_different_identities(result, original)
71
+ assert result["file"] is file_bytes
72
+
73
+ def test_list_popped_wholesale(self) -> None:
74
+ files = [b"f1", b"f2"]
75
+ original = {"files": files, "title": "t"}
76
+ result = deepcopy_with_paths(original, [["files", "<array>"]])
77
+ assert_different_identities(result, original)
78
+ result_files = result["files"]
79
+ assert isinstance(result_files, list)
80
+ assert_different_identities(result_files, files)
81
+
82
+ def test_nested_array_path_copies_list_and_elements(self) -> None:
83
+ elem1 = {"file": b"f1", "extra": 1}
84
+ elem2 = {"file": b"f2", "extra": 2}
85
+ original = {"items": [elem1, elem2]}
86
+ result = deepcopy_with_paths(original, [["items", "<array>", "file"]])
87
+ assert_different_identities(result, original)
88
+ result_items = result["items"]
89
+ assert isinstance(result_items, list)
90
+ assert_different_identities(result_items, original["items"])
91
+ assert_different_identities(result_items[0], elem1)
92
+ assert_different_identities(result_items[1], elem2)
93
+
94
+ def test_empty_paths_returns_same_object(self) -> None:
95
+ original = {"foo": "bar"}
96
+ result = deepcopy_with_paths(original, [])
97
+ assert result is original
98
+
99
+ def test_multiple_paths(self) -> None:
100
+ f1 = b"file1"
101
+ f2 = b"file2"
102
+ original = {"a": f1, "b": f2, "c": "unchanged"}
103
+ result = deepcopy_with_paths(original, [["a"], ["b"]])
104
+ assert_different_identities(result, original)
105
+ assert result["a"] is f1
106
+ assert result["b"] is f2
107
+ assert result["c"] is original["c"]
108
+
109
+ def test_extract_files_does_not_mutate_original_top_level(self) -> None:
110
+ file_bytes = b"contents"
111
+ original = {"file": file_bytes, "other": "value"}
112
+
113
+ copied = deepcopy_with_paths(original, [["file"]])
114
+ extracted = extract_files(copied, paths=[["file"]])
115
+
116
+ assert extracted == [("file", file_bytes)]
117
+ assert original == {"file": file_bytes, "other": "value"}
118
+ assert copied == {"other": "value"}
119
+
120
+ def test_extract_files_does_not_mutate_original_nested_array_path(self) -> None:
121
+ file1 = b"f1"
122
+ file2 = b"f2"
123
+ original = {
124
+ "items": [
125
+ {"file": file1, "extra": 1},
126
+ {"file": file2, "extra": 2},
127
+ ],
128
+ "title": "example",
129
+ }
130
+
131
+ copied = deepcopy_with_paths(original, [["items", "<array>", "file"]])
132
+ extracted = extract_files(copied, paths=[["items", "<array>", "file"]])
133
+
134
+ assert [entry for _, entry in extracted] == [file1, file2]
135
+ assert original == {
136
+ "items": [
137
+ {"file": file1, "extra": 1},
138
+ {"file": file2, "extra": 2},
139
+ ],
140
+ "title": "example",
141
+ }
142
+ assert copied == {
143
+ "items": [
144
+ {"extra": 1},
145
+ {"extra": 2},
146
+ ],
147
+ "title": "example",
148
+ }
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.36.0"
3
- }
@@ -1,58 +0,0 @@
1
- from gmt._utils import deepcopy_minimal
2
-
3
-
4
- def assert_different_identities(obj1: object, obj2: object) -> None:
5
- assert obj1 == obj2
6
- assert id(obj1) != id(obj2)
7
-
8
-
9
- def test_simple_dict() -> None:
10
- obj1 = {"foo": "bar"}
11
- obj2 = deepcopy_minimal(obj1)
12
- assert_different_identities(obj1, obj2)
13
-
14
-
15
- def test_nested_dict() -> None:
16
- obj1 = {"foo": {"bar": True}}
17
- obj2 = deepcopy_minimal(obj1)
18
- assert_different_identities(obj1, obj2)
19
- assert_different_identities(obj1["foo"], obj2["foo"])
20
-
21
-
22
- def test_complex_nested_dict() -> None:
23
- obj1 = {"foo": {"bar": [{"hello": "world"}]}}
24
- obj2 = deepcopy_minimal(obj1)
25
- assert_different_identities(obj1, obj2)
26
- assert_different_identities(obj1["foo"], obj2["foo"])
27
- assert_different_identities(obj1["foo"]["bar"], obj2["foo"]["bar"])
28
- assert_different_identities(obj1["foo"]["bar"][0], obj2["foo"]["bar"][0])
29
-
30
-
31
- def test_simple_list() -> None:
32
- obj1 = ["a", "b", "c"]
33
- obj2 = deepcopy_minimal(obj1)
34
- assert_different_identities(obj1, obj2)
35
-
36
-
37
- def test_nested_list() -> None:
38
- obj1 = ["a", [1, 2, 3]]
39
- obj2 = deepcopy_minimal(obj1)
40
- assert_different_identities(obj1, obj2)
41
- assert_different_identities(obj1[1], obj2[1])
42
-
43
-
44
- class MyObject: ...
45
-
46
-
47
- def test_ignores_other_types() -> None:
48
- # custom classes
49
- my_obj = MyObject()
50
- obj1 = {"foo": my_obj}
51
- obj2 = deepcopy_minimal(obj1)
52
- assert_different_identities(obj1, obj2)
53
- assert obj1["foo"] is my_obj
54
-
55
- # tuples
56
- obj3 = ("a", "b")
57
- obj4 = deepcopy_minimal(obj3)
58
- assert obj3 is obj4
@@ -1,51 +0,0 @@
1
- from pathlib import Path
2
-
3
- import anyio
4
- import pytest
5
- from dirty_equals import IsDict, IsList, IsBytes, IsTuple
6
-
7
- from gmt._files import to_httpx_files, async_to_httpx_files
8
-
9
- readme_path = Path(__file__).parent.parent.joinpath("README.md")
10
-
11
-
12
- def test_pathlib_includes_file_name() -> None:
13
- result = to_httpx_files({"file": readme_path})
14
- print(result)
15
- assert result == IsDict({"file": IsTuple("README.md", IsBytes())})
16
-
17
-
18
- def test_tuple_input() -> None:
19
- result = to_httpx_files([("file", readme_path)])
20
- print(result)
21
- assert result == IsList(IsTuple("file", IsTuple("README.md", IsBytes())))
22
-
23
-
24
- @pytest.mark.asyncio
25
- async def test_async_pathlib_includes_file_name() -> None:
26
- result = await async_to_httpx_files({"file": readme_path})
27
- print(result)
28
- assert result == IsDict({"file": IsTuple("README.md", IsBytes())})
29
-
30
-
31
- @pytest.mark.asyncio
32
- async def test_async_supports_anyio_path() -> None:
33
- result = await async_to_httpx_files({"file": anyio.Path(readme_path)})
34
- print(result)
35
- assert result == IsDict({"file": IsTuple("README.md", IsBytes())})
36
-
37
-
38
- @pytest.mark.asyncio
39
- async def test_async_tuple_input() -> None:
40
- result = await async_to_httpx_files([("file", readme_path)])
41
- print(result)
42
- assert result == IsList(IsTuple("file", IsTuple("README.md", IsBytes())))
43
-
44
-
45
- def test_string_not_allowed() -> None:
46
- with pytest.raises(TypeError, match="Expected file types input to be a FileContent type or to be a tuple"):
47
- to_httpx_files(
48
- {
49
- "file": "foo", # type: ignore
50
- }
51
- )
File without changes
File without changes
File without changes