@typespec/http-client-python 0.8.2 → 0.8.3-dev.1

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 (74) hide show
  1. package/README.md +0 -6
  2. package/dist/emitter/code-model.d.ts.map +1 -1
  3. package/dist/emitter/code-model.js +3 -0
  4. package/dist/emitter/code-model.js.map +1 -1
  5. package/dist/emitter/lib.d.ts +0 -1
  6. package/dist/emitter/lib.d.ts.map +1 -1
  7. package/dist/emitter/lib.js +0 -5
  8. package/dist/emitter/lib.js.map +1 -1
  9. package/emitter/src/code-model.ts +3 -0
  10. package/emitter/src/lib.ts +0 -7
  11. package/emitter/temp/tsconfig.tsbuildinfo +1 -1
  12. package/eng/scripts/ci/pylintrc +1 -1
  13. package/eng/scripts/ci/regenerate.ts +0 -3
  14. package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
  15. package/generator/build/lib/pygen/codegen/__init__.py +7 -21
  16. package/generator/build/lib/pygen/codegen/_utils.py +26 -2
  17. package/generator/build/lib/pygen/codegen/models/code_model.py +33 -0
  18. package/generator/build/lib/pygen/codegen/serializers/__init__.py +3 -1
  19. package/generator/build/lib/pygen/codegen/templates/client_container.py.jinja2 +3 -1
  20. package/generator/build/lib/pygen/codegen/templates/config_container.py.jinja2 +3 -1
  21. package/generator/build/lib/pygen/codegen/templates/conftest.py.jinja2 +3 -1
  22. package/generator/build/lib/pygen/codegen/templates/enum_container.py.jinja2 +3 -1
  23. package/generator/build/lib/pygen/codegen/templates/init.py.jinja2 +3 -1
  24. package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +3 -5
  25. package/generator/build/lib/pygen/codegen/templates/model_container.py.jinja2 +3 -1
  26. package/generator/build/lib/pygen/codegen/templates/model_init.py.jinja2 +3 -1
  27. package/generator/build/lib/pygen/codegen/templates/operation_groups_container.py.jinja2 +3 -1
  28. package/generator/build/lib/pygen/codegen/templates/operations_folder_init.py.jinja2 +3 -1
  29. package/generator/build/lib/pygen/codegen/templates/packaging_templates/LICENSE.jinja2 +1 -21
  30. package/generator/build/lib/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +6 -4
  31. package/generator/build/lib/pygen/codegen/templates/patch.py.jinja2 +9 -4
  32. package/generator/build/lib/pygen/codegen/templates/request_builders.py.jinja2 +3 -1
  33. package/generator/build/lib/pygen/codegen/templates/rest_init.py.jinja2 +3 -1
  34. package/generator/build/lib/pygen/codegen/templates/sample.py.jinja2 +3 -1
  35. package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +4 -25
  36. package/generator/build/lib/pygen/codegen/templates/test.py.jinja2 +3 -1
  37. package/generator/build/lib/pygen/codegen/templates/testpreparer.py.jinja2 +3 -1
  38. package/generator/build/lib/pygen/codegen/templates/types.py.jinja2 +3 -1
  39. package/generator/build/lib/pygen/codegen/templates/validation.py.jinja2 +3 -1
  40. package/generator/build/lib/pygen/codegen/templates/vendor.py.jinja2 +3 -1
  41. package/generator/build/lib/pygen/codegen/templates/version.py.jinja2 +3 -1
  42. package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
  43. package/generator/pygen/codegen/__init__.py +7 -21
  44. package/generator/pygen/codegen/_utils.py +26 -2
  45. package/generator/pygen/codegen/models/code_model.py +33 -0
  46. package/generator/pygen/codegen/serializers/__init__.py +3 -1
  47. package/generator/pygen/codegen/templates/client_container.py.jinja2 +3 -1
  48. package/generator/pygen/codegen/templates/config_container.py.jinja2 +3 -1
  49. package/generator/pygen/codegen/templates/conftest.py.jinja2 +3 -1
  50. package/generator/pygen/codegen/templates/enum_container.py.jinja2 +3 -1
  51. package/generator/pygen/codegen/templates/init.py.jinja2 +3 -1
  52. package/generator/pygen/codegen/templates/model_base.py.jinja2 +3 -5
  53. package/generator/pygen/codegen/templates/model_container.py.jinja2 +3 -1
  54. package/generator/pygen/codegen/templates/model_init.py.jinja2 +3 -1
  55. package/generator/pygen/codegen/templates/operation_groups_container.py.jinja2 +3 -1
  56. package/generator/pygen/codegen/templates/operations_folder_init.py.jinja2 +3 -1
  57. package/generator/pygen/codegen/templates/packaging_templates/LICENSE.jinja2 +1 -21
  58. package/generator/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +6 -4
  59. package/generator/pygen/codegen/templates/patch.py.jinja2 +9 -4
  60. package/generator/pygen/codegen/templates/request_builders.py.jinja2 +3 -1
  61. package/generator/pygen/codegen/templates/rest_init.py.jinja2 +3 -1
  62. package/generator/pygen/codegen/templates/sample.py.jinja2 +3 -1
  63. package/generator/pygen/codegen/templates/serialization.py.jinja2 +4 -25
  64. package/generator/pygen/codegen/templates/test.py.jinja2 +3 -1
  65. package/generator/pygen/codegen/templates/testpreparer.py.jinja2 +3 -1
  66. package/generator/pygen/codegen/templates/types.py.jinja2 +3 -1
  67. package/generator/pygen/codegen/templates/validation.py.jinja2 +3 -1
  68. package/generator/pygen/codegen/templates/vendor.py.jinja2 +3 -1
  69. package/generator/pygen/codegen/templates/version.py.jinja2 +3 -1
  70. package/generator/test/azure/requirements.txt +1 -0
  71. package/generator/test/generic_mock_api_tests/asynctests/test_streaming_jsonl_async.py +27 -0
  72. package/generator/test/generic_mock_api_tests/test_streaming_jsonl.py +25 -0
  73. package/generator/test/unbranded/requirements.txt +1 -0
  74. package/package.json +8 -2
@@ -2,7 +2,9 @@
2
2
  {% import 'operation_tools.jinja2' as op_tools %}
3
3
  {# actual template starts here #}
4
4
  # coding=utf-8
5
- {{ code_model.options['license_header'] }}
5
+ {% if code_model.license_header %}
6
+ {{ code_model.license_header }}
7
+ {% endif %}
6
8
 
7
9
  {{ imports }}
8
10
 
@@ -2,7 +2,9 @@
2
2
  {% import 'operation_tools.jinja2' as op_tools %}
3
3
  {# actual template starts here #}
4
4
  # coding=utf-8
5
- {{ code_model.options['license_header'] }}
5
+ {% if code_model.license_header %}
6
+ {{ code_model.license_header }}
7
+ {% endif %}
6
8
 
7
9
  {{ imports }}
8
10
 
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
  import os
4
6
  import pytest
5
7
  from dotenv import load_dotenv
@@ -1,6 +1,8 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
 
5
7
  from enum import Enum
6
8
  from {{ code_model.core_library }}{{ "" if code_model.is_azure_flavor else ".utils" }} import CaseInsensitiveEnumMeta
@@ -1,6 +1,8 @@
1
1
  {% import 'keywords.jinja2' as keywords %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
  {{ keywords.path_type_checking_imports() }}
5
7
  {% if clients %}
6
8
  {% for client in clients %}
@@ -1,9 +1,7 @@
1
1
  # coding=utf-8
2
- # --------------------------------------------------------------------------
3
- # Copyright (c) {{ code_model.options["company_name"] }} Corporation. All rights reserved.
4
- # Licensed under the MIT License. See License.txt in the project root for
5
- # license information.
6
- # --------------------------------------------------------------------------
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
7
5
  # pylint: disable=protected-access, broad-except
8
6
 
9
7
  import copy
@@ -1,6 +1,8 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
  {% if serializer.global_pylint_disables() %}
5
7
  {{ serializer.global_pylint_disables() }}
6
8
  {% endif %}
@@ -1,6 +1,8 @@
1
1
  {% import 'keywords.jinja2' as keywords %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
  {{ keywords.path_type_checking_imports() }}
5
7
  {% if schemas %}
6
8
 
@@ -2,7 +2,9 @@
2
2
  {% set operations_description = "async operations" if async_mode else "operations" %}
3
3
  {% set return_none_type_annotation = " -> None" if async_mode else "" %}
4
4
  # coding=utf-8
5
- {{ code_model.options['license_header'] }}
5
+ {% if code_model.license_header %}
6
+ {{ code_model.license_header }}
7
+ {% endif %}
6
8
  {{ imports }}
7
9
  {{ unset }}
8
10
  {% if code_model.options["builders_visibility"] == "embedded" and not async_mode %}
@@ -2,7 +2,9 @@
2
2
  {% import 'keywords.jinja2' as keywords %}
3
3
  {# actual template starts here #}
4
4
  # coding=utf-8
5
- {{ code_model.options['license_header'] }}
5
+ {% if code_model.license_header %}
6
+ {{ code_model.license_header }}
7
+ {% endif %}
6
8
  {{ keywords.path_type_checking_imports() }}
7
9
  {{ op_tools.serialize(operation_group_imports()) }}
8
10
  {{ keywords.patch_imports() }}
@@ -1,21 +1 @@
1
- Copyright (c) {{ code_model.options["company_name"] }} Corporation.
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ {{ code_model.license_description }}
@@ -1,6 +1,8 @@
1
1
  # coding=utf-8
2
- {{ license_header }}
3
- # coding: utf-8
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
5
+
4
6
  {% if package_mode %}
5
7
 
6
8
  import os
@@ -32,7 +34,7 @@ with open(os.path.join(package_folder_path, "_version.py"), "r") as fd:
32
34
 
33
35
  if not version:
34
36
  raise RuntimeError("Cannot find version information")
35
- {% set description = "\"" + code_model.options["company_name"] + " {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
37
+ {% set description = "\"" + code_model.company_name + " {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
36
38
  {% set author_email = "azpysdkhelp@microsoft.com" %}
37
39
  {% set url = "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk" %}
38
40
  {% else %}
@@ -52,7 +54,7 @@ setup(
52
54
  long_description=open("README.md", "r").read(),
53
55
  long_description_content_type="text/markdown",
54
56
  license="MIT License",
55
- author="{{ code_model.options["company_name"] }} Corporation",
57
+ author="{{ code_model.company_name }}",
56
58
  {% endif %}
57
59
  {% if code_model.is_azure_flavor %}
58
60
  author_email="{{ author_email }}",
@@ -1,7 +1,12 @@
1
- # ------------------------------------
2
- # Copyright (c) {{ code_model.options["company_name"] }} Corporation.
3
- # Licensed under the MIT License.
4
- # ------------------------------------
1
+ # coding=utf-8
2
+ {% if not code_model.is_azure_flavor %}
3
+ {{ code_model.license_header }}
4
+ {% else %}
5
+ # --------------------------------------------------------------------------
6
+ # Copyright (c) Microsoft Corporation. All rights reserved.
7
+ # Licensed under the MIT License. See License.txt in the project root for license information.
8
+ # --------------------------------------------------------------------------
9
+ {% endif %}
5
10
  """Customize generated code here.
6
11
 
7
12
  Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
@@ -1,6 +1,8 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
  {{ imports }}
5
7
 
6
8
  {{ op_tools.declare_serializer(code_model) }}
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
 
4
6
  {% for request_builder in request_builders %}
5
7
  from ._request_builders import {{ request_builder.name }}
@@ -1,7 +1,9 @@
1
1
  # coding=utf-8
2
2
  {% set aad_token = "DefaultAzureCredential" %}
3
3
  {% set azure_key = "AzureKeyCredential" %}
4
- {{ code_model.options['license_header'] }}
4
+ {% if code_model.license_header %}
5
+ {{ code_model.license_header }}
6
+ {% endif %}
5
7
 
6
8
  {{ imports }}
7
9
  """
@@ -1,28 +1,7 @@
1
- # --------------------------------------------------------------------------
2
- #
3
- # Copyright (c) {{ code_model.options["company_name"] }} Corporation. All rights reserved.
4
- #
5
- # The MIT License (MIT)
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the ""Software""), to
9
- # deal in the Software without restriction, including without limitation the
10
- # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
- # sell copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in
15
- # all copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
- # IN THE SOFTWARE.
24
- #
25
- # --------------------------------------------------------------------------
1
+ # coding=utf-8
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
26
5
 
27
6
  # pyright: reportUnnecessaryTypeIgnoreComment=false
28
7
 
@@ -3,7 +3,9 @@
3
3
  {% set async = "async " if test.async_mode else "" %}
4
4
  {% set async_suffix = "_async" if test.async_mode else "" %}
5
5
  # coding=utf-8
6
- {{ code_model.options['license_header'] }}
6
+ {% if code_model.license_header %}
7
+ {{ code_model.license_header }}
8
+ {% endif %}
7
9
  import pytest
8
10
  {{ imports }}
9
11
 
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
  {{ imports }}
4
6
 
5
7
  {% for test_name in test_names %}
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
 
4
6
  {{ imports }}
5
7
  {% for nu in code_model.named_unions %}
@@ -1,4 +1,6 @@
1
- {{ code_model.options['license_header'] }}
1
+ {% if code_model.license_header %}
2
+ {{ code_model.license_header }}
3
+ {% endif %}
2
4
  import functools
3
5
 
4
6
  def api_version_validation(**kwargs):
@@ -1,5 +1,7 @@
1
1
  {% import 'keywords.jinja2' as keywords with context %}
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
 
4
6
  {{ imports }}
5
7
 
@@ -1,4 +1,6 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
 
4
6
  VERSION = "{{ code_model.options['package_version'] }}"
@@ -46,6 +46,7 @@ azure-mgmt-core==1.3.2
46
46
  -e ./generated/server-versions-versioned
47
47
  -e ./generated/server-versions-not-versioned
48
48
  -e ./generated/special-words
49
+ -e ./generated/streaming-jsonl
49
50
  -e ./generated/typetest-array
50
51
  -e ./generated/typetest-dictionary
51
52
  -e ./generated/typetest-enum-extensible
@@ -0,0 +1,27 @@
1
+ # -------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for
4
+ # license information.
5
+ # --------------------------------------------------------------------------
6
+ import pytest
7
+
8
+ from streaming.jsonl.aio import JsonlClient
9
+
10
+
11
+ @pytest.fixture
12
+ async def client():
13
+ async with JsonlClient(endpoint="http://localhost:3000") as client:
14
+ yield client
15
+
16
+
17
+ JSONL = b'{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}'
18
+
19
+
20
+ @pytest.mark.asyncio
21
+ async def test_basic_send(client: JsonlClient):
22
+ await client.basic.send(JSONL)
23
+
24
+
25
+ @pytest.mark.asyncio
26
+ async def test_basic_recv(client: JsonlClient):
27
+ assert b"".join([d async for d in (await client.basic.receive())]) == JSONL
@@ -0,0 +1,25 @@
1
+ # -------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for
4
+ # license information.
5
+ # --------------------------------------------------------------------------
6
+ import pytest
7
+
8
+ from streaming.jsonl import JsonlClient
9
+
10
+
11
+ @pytest.fixture
12
+ def client():
13
+ with JsonlClient(endpoint="http://localhost:3000") as client:
14
+ yield client
15
+
16
+
17
+ JSONL = b'{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}'
18
+
19
+
20
+ def test_basic_send(client: JsonlClient):
21
+ client.basic.send(JSONL)
22
+
23
+
24
+ def test_basic_recv(client: JsonlClient):
25
+ assert b"".join(client.basic.receive()) == JSONL
@@ -18,6 +18,7 @@
18
18
  -e ./generated/server-versions-versioned
19
19
  -e ./generated/server-versions-not-versioned
20
20
  -e ./generated/special-words
21
+ -e ./generated/streaming-jsonl
21
22
  -e ./generated/typetest-array
22
23
  -e ./generated/typetest-dictionary
23
24
  -e ./generated/typetest-enum-extensible
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http-client-python",
3
- "version": "0.8.2",
3
+ "version": "0.8.3-dev.1",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec emitter for Python SDKs",
6
6
  "homepage": "https://typespec.io",
@@ -63,7 +63,10 @@
63
63
  "@typespec/http": ">=0.67.0 <1.0.0",
64
64
  "@typespec/openapi": ">=0.67.0 <1.0.0",
65
65
  "@typespec/rest": ">=0.67.0 <1.0.0",
66
- "@typespec/versioning": ">=0.67.0 <1.0.0"
66
+ "@typespec/versioning": ">=0.67.0 <1.0.0",
67
+ "@typespec/events": ">=0.67.0 <1.0.0",
68
+ "@typespec/sse": ">=0.67.0 <1.0.0",
69
+ "@typespec/streams": ">=0.67.0 <1.0.0"
67
70
  },
68
71
  "dependencies": {
69
72
  "js-yaml": "~4.1.0",
@@ -88,6 +91,9 @@
88
91
  "@typespec/openapi": "~0.67.0",
89
92
  "@typespec/rest": "~0.67.0",
90
93
  "@typespec/versioning": "~0.67.0",
94
+ "@typespec/events": "~0.67.0",
95
+ "@typespec/sse": "~0.67.0",
96
+ "@typespec/streams": "~0.67.0",
91
97
  "c8": "^10.1.3",
92
98
  "chalk": "5.3.0",
93
99
  "rimraf": "~6.0.1",