@typespec/http-client-python 0.8.0 → 0.9.0-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 (57) hide show
  1. package/dist/emitter/code-model.d.ts.map +1 -1
  2. package/dist/emitter/code-model.js +2 -2
  3. package/dist/emitter/code-model.js.map +1 -1
  4. package/dist/emitter/emitter.d.ts.map +1 -1
  5. package/dist/emitter/emitter.js +9 -5
  6. package/dist/emitter/emitter.js.map +1 -1
  7. package/dist/emitter/lib.d.ts +11 -2
  8. package/dist/emitter/lib.d.ts.map +1 -1
  9. package/dist/emitter/lib.js +7 -1
  10. package/dist/emitter/lib.js.map +1 -1
  11. package/dist/emitter/types.js +2 -2
  12. package/dist/emitter/types.js.map +1 -1
  13. package/dist/emitter/utils.d.ts +1 -0
  14. package/dist/emitter/utils.d.ts.map +1 -1
  15. package/dist/emitter/utils.js +31 -16
  16. package/dist/emitter/utils.js.map +1 -1
  17. package/emitter/src/code-model.ts +2 -7
  18. package/emitter/src/emitter.ts +9 -7
  19. package/emitter/src/lib.ts +8 -4
  20. package/emitter/src/types.ts +2 -2
  21. package/emitter/src/utils.ts +32 -18
  22. package/emitter/temp/tsconfig.tsbuildinfo +1 -1
  23. package/eng/scripts/ci/regenerate.ts +96 -41
  24. package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
  25. package/generator/build/lib/pygen/codegen/__init__.py +0 -2
  26. package/generator/build/lib/pygen/codegen/models/code_model.py +5 -5
  27. package/generator/build/lib/pygen/codegen/serializers/__init__.py +18 -14
  28. package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +5 -2
  29. package/generator/build/lib/pygen/codegen/serializers/test_serializer.py +1 -1
  30. package/generator/build/lib/pygen/codegen/templates/packaging_templates/MANIFEST.in.jinja2 +6 -2
  31. package/generator/build/lib/pygen/codegen/templates/packaging_templates/README.md.jinja2 +5 -5
  32. package/generator/build/lib/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +3 -3
  33. package/generator/build/lib/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +14 -5
  34. package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
  35. package/generator/pygen/codegen/__init__.py +0 -2
  36. package/generator/pygen/codegen/models/code_model.py +5 -5
  37. package/generator/pygen/codegen/serializers/__init__.py +18 -14
  38. package/generator/pygen/codegen/serializers/general_serializer.py +5 -2
  39. package/generator/pygen/codegen/serializers/test_serializer.py +1 -1
  40. package/generator/pygen/codegen/templates/packaging_templates/MANIFEST.in.jinja2 +6 -2
  41. package/generator/pygen/codegen/templates/packaging_templates/README.md.jinja2 +5 -5
  42. package/generator/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +3 -3
  43. package/generator/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +14 -5
  44. package/generator/pygen.egg-info/PKG-INFO +2 -2
  45. package/generator/pygen.egg-info/requires.txt +2 -2
  46. package/generator/setup.py +2 -2
  47. package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py +1 -0
  48. package/generator/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py +1 -0
  49. package/generator/test/azure/tox.ini +2 -2
  50. package/generator/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +4 -3
  51. package/generator/test/generic_mock_api_tests/asynctests/test_parameters_collection_format_async.py +0 -6
  52. package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py +1 -0
  53. package/generator/test/generic_mock_api_tests/test_encode_bytes.py +4 -3
  54. package/generator/test/generic_mock_api_tests/test_parameters_collection_format.py +0 -4
  55. package/generator/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py +1 -0
  56. package/generator/test/unbranded/tox.ini +2 -2
  57. package/package.json +25 -25
@@ -1,5 +1,5 @@
1
1
  {% if code_model.is_azure_flavor %}
2
- {% if package_mode == "mgmtplane" -%}
2
+ {% if package_mode == "mgmtplane" %}
3
3
  # Microsoft Azure SDK for Python
4
4
 
5
5
  This is the Microsoft {{package_pprint_name}} Client Library.
@@ -40,7 +40,7 @@ python -m pip install {{ package_name }}
40
40
  - You need an [Azure subscription][azure_sub] to use this package.
41
41
  - An existing {{ package_pprint_name }} instance.
42
42
 
43
- {%- if token_credential %}
43
+ {% if token_credential %}
44
44
  #### Create with an Azure Active Directory Credential
45
45
  To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
46
46
  provide an instance of the desired credential type obtained from the
@@ -57,7 +57,7 @@ Set the values of the client ID, tenant ID, and client secret of the AAD applica
57
57
  Use the returned token credential to authenticate the client:
58
58
 
59
59
  ```python
60
- >>> from {{ namespace }} import {{ client_name }}
60
+ >>> from {{ code_model.namespace }} import {{ client_name }}
61
61
  >>> from azure.identity import DefaultAzureCredential
62
62
  >>> client = {{ client_name }}(endpoint='<endpoint>', credential=DefaultAzureCredential())
63
63
  ```
@@ -65,7 +65,7 @@ Use the returned token credential to authenticate the client:
65
65
  ## Examples
66
66
 
67
67
  ```python
68
- >>> from {{ namespace }} import {{ client_name }}
68
+ >>> from {{ code_model.namespace }} import {{ client_name }}
69
69
  >>> from azure.identity import DefaultAzureCredential
70
70
  >>> from {{ code_model.core_library }}.exceptions import HttpResponseError
71
71
 
@@ -76,7 +76,7 @@ Use the returned token credential to authenticate the client:
76
76
  print('service responds error: {}'.format(e.response.json()))
77
77
 
78
78
  ```
79
- {%- endif %}
79
+ {% endif %}
80
80
 
81
81
  ## Contributing
82
82
 
@@ -1,9 +1,9 @@
1
1
  -e ../../../tools/azure-sdk-tools
2
2
  ../../core/azure-core
3
- {% if token_credential -%}
3
+ {% if token_credential %}
4
4
  ../../identity/azure-identity
5
5
  {% endif -%}
6
- {% if azure_arm -%}
6
+ {% if azure_arm %}
7
7
  ../../core/azure-mgmt-core
8
- {% endif -%}
8
+ {% endif %}
9
9
  aiohttp
@@ -2,19 +2,27 @@
2
2
  {{ license_header }}
3
3
  # coding: utf-8
4
4
  {% if package_mode %}
5
+
5
6
  import os
6
7
  import re
7
- {% endif -%}
8
+ {% endif %}
8
9
  from setuptools import setup, find_packages
9
10
 
10
11
  {% set package_name = package_name or code_model.clients[0].name %}
11
12
 
12
13
  PACKAGE_NAME = "{{ package_name|lower }}"
13
- {% if package_mode -%}
14
+ {% if package_mode %}
14
15
  PACKAGE_PPRINT_NAME = "{{ package_pprint_name }}"
16
+ {% if code_model.is_tsp %}
17
+ PACKAGE_NAMESPACE = "{{ code_model.namespace|lower }}"
18
+
19
+ # a.b.c => a/b/c
20
+ package_folder_path = PACKAGE_NAMESPACE.replace(".", "/")
21
+ {% else %}
15
22
 
16
23
  # a-b-c => a/b/c
17
24
  package_folder_path = PACKAGE_NAME.replace("-", "/")
25
+ {% endif %}
18
26
 
19
27
  # Version extraction inspired from 'requests'
20
28
  with open(os.path.join(package_folder_path, "_version.py"), "r") as fd:
@@ -33,7 +41,8 @@ version = "{{ package_version }}"
33
41
  {% set long_description = code_model.description %}
34
42
  {% set author_email = "" %}
35
43
  {% set url = "" %}
36
- {% endif -%}
44
+ {% endif %}
45
+
37
46
 
38
47
  setup(
39
48
  name=PACKAGE_NAME,
@@ -70,9 +79,9 @@ setup(
70
79
  {% if pkgutil_names %}
71
80
  # Exclude packages that will be covered by PEP420 or nspkg
72
81
  {% endif %}
73
- {%- for pkgutil_name in pkgutil_names %}
82
+ {% for pkgutil_name in pkgutil_names %}
74
83
  "{{ pkgutil_name }}",
75
- {%- endfor %}
84
+ {% endfor %}
76
85
  ]
77
86
  ),
78
87
  include_package_data=True,
@@ -19,9 +19,9 @@ Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: black==24.8.0
21
21
  Requires-Dist: docutils>=0.20.1
22
- Requires-Dist: Jinja2==3.1.3
22
+ Requires-Dist: Jinja2==3.1.6
23
23
  Requires-Dist: PyYAML==6.0.1
24
24
  Requires-Dist: tomli==2.0.1
25
- Requires-Dist: setuptools==69.5.1
25
+ Requires-Dist: setuptools==70.0.0
26
26
 
27
27
  # Core Library for Python Generation
@@ -1,6 +1,6 @@
1
1
  black==24.8.0
2
2
  docutils>=0.20.1
3
- Jinja2==3.1.3
3
+ Jinja2==3.1.6
4
4
  PyYAML==6.0.1
5
5
  tomli==2.0.1
6
- setuptools==69.5.1
6
+ setuptools==70.0.0
@@ -50,9 +50,9 @@ setup(
50
50
  install_requires=[
51
51
  "black==24.8.0",
52
52
  "docutils>=0.20.1",
53
- "Jinja2==3.1.3",
53
+ "Jinja2==3.1.6",
54
54
  "PyYAML==6.0.1",
55
55
  "tomli==2.0.1",
56
- "setuptools==69.5.1",
56
+ "setuptools==70.0.0",
57
57
  ],
58
58
  )
@@ -18,6 +18,7 @@ async def client(credential, authentication_policy):
18
18
  SUBSCRIPTION_ID,
19
19
  "http://localhost:3000",
20
20
  authentication_policy=authentication_policy,
21
+ polling_interval=0,
21
22
  ) as client:
22
23
  yield client
23
24
 
@@ -18,6 +18,7 @@ def client(credential, authentication_policy):
18
18
  SUBSCRIPTION_ID,
19
19
  "http://localhost:3000",
20
20
  authentication_policy=authentication_policy,
21
+ polling_interval=0,
21
22
  ) as client:
22
23
  yield client
23
24
 
@@ -10,7 +10,7 @@ commands =
10
10
  pytest mock_api_tests ../generic_mock_api_tests
11
11
 
12
12
  # pylint
13
- pip install azure-pylint-guidelines-checker==0.5.1 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
13
+ pip install azure-pylint-guidelines-checker==0.5.2 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
14
14
  python ../../../eng/scripts/ci/run_pylint.py -t azure -s "generated" {posargs}
15
15
 
16
16
  # mypy
@@ -33,7 +33,7 @@ commands =
33
33
  deps=
34
34
  -r requirements.txt
35
35
  commands =
36
- pip install azure-pylint-guidelines-checker==0.5.1 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
36
+ pip install azure-pylint-guidelines-checker==0.5.2 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
37
37
  python ../../../eng/scripts/ci/run_pylint.py -t azure -s "generated" {posargs}
38
38
 
39
39
  [testenv:mypy]
@@ -107,7 +107,7 @@ def png_data() -> bytes:
107
107
  @pytest.mark.asyncio
108
108
  async def test_request_body(client: BytesClient, png_data: bytes):
109
109
  await client.request_body.default(
110
- value=bytes("test", "utf-8"),
110
+ value=png_data,
111
111
  )
112
112
  await client.request_body.octet_stream(
113
113
  value=png_data,
@@ -126,8 +126,9 @@ async def test_request_body(client: BytesClient, png_data: bytes):
126
126
  @pytest.mark.asyncio
127
127
  async def test_response_body(client: BytesClient, png_data: bytes):
128
128
  expected = b"test"
129
- assert expected == await client.response_body.default()
129
+ assert b"".join([d async for d in (await client.response_body.default())]) == png_data
130
130
  assert expected == await client.response_body.base64()
131
- assert expected == await client.response_body.base64_url()
132
131
  assert b"".join([d async for d in (await client.response_body.octet_stream())]) == png_data
133
132
  assert b"".join([d async for d in (await client.response_body.custom_content_type())]) == png_data
133
+ # will reopen after TCGC release a fix version for https://github.com/Azure/typespec-azure/pull/2411
134
+ # assert expected == await client.response_body.base64_url()
@@ -33,12 +33,6 @@ async def test_query_ssv(client: CollectionFormatClient):
33
33
  await client.query.ssv(colors=["blue", "red", "green"])
34
34
 
35
35
 
36
- @pytest.mark.asyncio
37
- @pytest.mark.skip(reason="https://github.com/aio-libs/aiohttp/issues/5904")
38
- async def test_query_tsv(client: CollectionFormatClient):
39
- await client.query.tsv(colors=["blue", "red", "green"])
40
-
41
-
42
36
  @pytest.mark.asyncio
43
37
  async def test_csv_header(client: CollectionFormatClient):
44
38
  await client.header.csv(colors=["blue", "red", "green"])
@@ -262,6 +262,7 @@ async def test_spread_model_array(client: AdditionalPropertiesClient):
262
262
  await client.spread_model_array.put(body)
263
263
 
264
264
 
265
+ @pytest.mark.skip(reason="https://github.com/microsoft/typespec/pull/6425")
265
266
  @pytest.mark.asyncio
266
267
  async def test_spread_record_discriminated_union(client: AdditionalPropertiesClient):
267
268
  body = {
@@ -103,7 +103,7 @@ def png_data() -> bytes:
103
103
 
104
104
  def test_request_body(client: BytesClient, png_data: bytes):
105
105
  client.request_body.default(
106
- value=bytes("test", "utf-8"),
106
+ value=png_data,
107
107
  )
108
108
  client.request_body.octet_stream(
109
109
  value=png_data,
@@ -121,8 +121,9 @@ def test_request_body(client: BytesClient, png_data: bytes):
121
121
 
122
122
  def test_response_body(client: BytesClient, png_data: bytes):
123
123
  expected = b"test"
124
- assert expected == client.response_body.default()
124
+ assert b"".join(client.response_body.default()) == png_data
125
125
  assert expected == client.response_body.base64()
126
- assert expected == client.response_body.base64_url()
127
126
  assert b"".join(client.response_body.octet_stream()) == png_data
128
127
  assert b"".join(client.response_body.custom_content_type()) == png_data
128
+ # will reopen after TCGC release a fix version for https://github.com/Azure/typespec-azure/pull/2411
129
+ # assert expected == client.response_body.base64_url()
@@ -29,9 +29,5 @@ def test_query_ssv(client: CollectionFormatClient):
29
29
  client.query.ssv(colors=["blue", "red", "green"])
30
30
 
31
31
 
32
- def test_query_tsv(client: CollectionFormatClient):
33
- client.query.tsv(colors=["blue", "red", "green"])
34
-
35
-
36
32
  def test_csv_header(client: CollectionFormatClient):
37
33
  client.header.csv(colors=["blue", "red", "green"])
@@ -236,6 +236,7 @@ def test_spread_model_array(client: AdditionalPropertiesClient):
236
236
  client.spread_model_array.put(body)
237
237
 
238
238
 
239
+ @pytest.mark.skip(reason="https://github.com/microsoft/typespec/pull/6425")
239
240
  def test_spread_record_discriminated_union(client: AdditionalPropertiesClient):
240
241
  body = {
241
242
  "name": "abc",
@@ -10,7 +10,7 @@ commands =
10
10
  pytest mock_api_tests ../generic_mock_api_tests
11
11
 
12
12
  # pylint
13
- pip install azure-pylint-guidelines-checker==0.5.1 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
13
+ pip install azure-pylint-guidelines-checker==0.5.2 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
14
14
  python ../../../eng/scripts/ci/run_pylint.py -t unbranded -s "generated" {posargs}
15
15
 
16
16
  # mypy
@@ -33,7 +33,7 @@ commands =
33
33
  deps=
34
34
  -r requirements.txt
35
35
  commands =
36
- pip install azure-pylint-guidelines-checker==0.5.1 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
36
+ pip install azure-pylint-guidelines-checker==0.5.2 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
37
37
  python ../../../eng/scripts/ci/run_pylint.py -t unbranded -s "generated" {posargs}
38
38
 
39
39
  [testenv:mypy]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http-client-python",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-dev.1",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec emitter for Python SDKs",
6
6
  "homepage": "https://typespec.io",
@@ -26,13 +26,13 @@
26
26
  }
27
27
  },
28
28
  "engines": {
29
- "node": ">=18.0.0"
29
+ "node": ">=20.0.0"
30
30
  },
31
31
  "scripts": {
32
32
  "clean": "rimraf ./dist ./temp ./emitter/temp ./generator/test/azure/generated ./generator/test/unbranded/generated ./venv",
33
33
  "build": "tsc -p ./emitter/tsconfig.build.json && tsx ./eng/scripts/setup/build.ts",
34
34
  "watch": "tsc -p ./emitter/tsconfig.build.json --watch",
35
- "lint": "eslint . --max-warnings=0",
35
+ "lint": "eslint emitter/ --max-warnings=0",
36
36
  "lint:py": "tsx ./eng/scripts/ci/lint.ts --folderName generator/pygen",
37
37
  "format": "pnpm -w format:dir packages/http-client-python && tsx ./eng/scripts/ci/format.ts",
38
38
  "install": "tsx ./eng/scripts/setup/install.ts",
@@ -53,16 +53,16 @@
53
53
  "emitter"
54
54
  ],
55
55
  "peerDependencies": {
56
- "@azure-tools/typespec-autorest": ">=0.52.0 <1.0.0",
57
- "@azure-tools/typespec-azure-core": ">=0.52.0 <1.0.0",
58
- "@azure-tools/typespec-azure-resource-manager": ">=0.52.0 <1.0.0",
59
- "@azure-tools/typespec-azure-rulesets": ">=0.52.0 <3.0.0",
60
- "@azure-tools/typespec-client-generator-core": ">=0.52.0 <1.0.0",
61
- "@typespec/compiler": ">=0.66.0 <1.0.0",
62
- "@typespec/http": ">=0.66.0 <1.0.0",
63
- "@typespec/openapi": ">=0.66.0 <1.0.0",
64
- "@typespec/rest": ">=0.66.0 <1.0.0",
65
- "@typespec/versioning": ">=0.66.0 <1.0.0"
56
+ "@azure-tools/typespec-autorest": ">=0.53.0 <1.0.0",
57
+ "@azure-tools/typespec-azure-core": ">=0.53.0 <1.0.0",
58
+ "@azure-tools/typespec-azure-resource-manager": ">=0.53.0 <1.0.0",
59
+ "@azure-tools/typespec-azure-rulesets": ">=0.53.0 <3.0.0",
60
+ "@azure-tools/typespec-client-generator-core": ">=0.53.1 <1.0.0",
61
+ "@typespec/compiler": ">=0.67.0 <1.0.0",
62
+ "@typespec/http": ">=0.67.0 <1.0.0",
63
+ "@typespec/openapi": ">=0.67.0 <1.0.0",
64
+ "@typespec/rest": ">=0.67.0 <1.0.0",
65
+ "@typespec/versioning": ">=0.67.0 <1.0.0"
66
66
  },
67
67
  "dependencies": {
68
68
  "js-yaml": "~4.1.0",
@@ -72,21 +72,21 @@
72
72
  "tsx": "~4.19.1"
73
73
  },
74
74
  "devDependencies": {
75
- "@azure-tools/azure-http-specs": "0.1.0-alpha.7",
76
- "@azure-tools/typespec-autorest": "~0.52.0",
77
- "@azure-tools/typespec-azure-core": "~0.52.0",
78
- "@azure-tools/typespec-azure-resource-manager": "~0.52.0",
79
- "@azure-tools/typespec-azure-rulesets": "~0.52.0",
80
- "@azure-tools/typespec-client-generator-core": "~0.52.0",
75
+ "@azure-tools/azure-http-specs": "0.1.0-alpha.10",
76
+ "@azure-tools/typespec-autorest": "~0.53.0",
77
+ "@azure-tools/typespec-azure-core": "~0.53.0",
78
+ "@azure-tools/typespec-azure-resource-manager": "~0.53.0",
79
+ "@azure-tools/typespec-azure-rulesets": "~0.53.0",
80
+ "@azure-tools/typespec-client-generator-core": "~0.53.1",
81
81
  "@types/js-yaml": "~4.0.5",
82
82
  "@types/node": "~22.5.4",
83
83
  "@types/semver": "7.5.8",
84
- "@typespec/compiler": "~0.66.0",
85
- "@typespec/http": "~0.66.0",
86
- "@typespec/http-specs": "0.1.0-alpha.11",
87
- "@typespec/openapi": "~0.66.0",
88
- "@typespec/rest": "~0.66.0",
89
- "@typespec/versioning": "~0.66.0",
84
+ "@typespec/compiler": "~0.67.0",
85
+ "@typespec/http": "~0.67.0",
86
+ "@typespec/http-specs": "0.1.0-alpha.15-dev.3",
87
+ "@typespec/openapi": "~0.67.0",
88
+ "@typespec/rest": "~0.67.0",
89
+ "@typespec/versioning": "~0.67.0",
90
90
  "c8": "^10.1.3",
91
91
  "chalk": "5.3.0",
92
92
  "rimraf": "~6.0.1",