@typespec/http-client-python 0.24.0 → 0.25.0
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.
- package/dist/emitter/code-model.d.ts.map +1 -1
- package/dist/emitter/code-model.js +10 -1
- package/dist/emitter/code-model.js.map +1 -1
- package/emitter/src/code-model.ts +9 -1
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/setup/__pycache__/package_manager.cpython-311.pyc +0 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-311.pyc +0 -0
- package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +20 -10
- package/generator/component-detection-pip-report.json +5 -4
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +20 -10
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py +17 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_payload_multipart_async.py +33 -0
- package/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py +5 -0
- package/generator/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py +13 -14
- package/generator/test/azure/mock_api_tests/test_payload_multipart.py +31 -0
- package/generator/test/azure/mock_api_tests/test_special_words.py +4 -0
- package/generator/test/azure/requirements.txt +1 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_array_async.py +96 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_specs_documentation_async.py +1 -2
- package/generator/test/generic_mock_api_tests/test_encode_array.py +88 -0
- package/generator/test/generic_mock_api_tests/test_specs_documentation.py +0 -1
- package/generator/test/unbranded/mock_api_tests/asynctests/test_payload_multipart_async.py +33 -0
- package/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py +23 -0
- package/generator/test/unbranded/mock_api_tests/test_payload_multipart.py +31 -0
- package/generator/test/unbranded/mock_api_tests/test_special_words.py +21 -0
- package/generator/test/unbranded/mock_api_tests/test_unbranded.py +8 -3
- package/generator/test/unbranded/requirements.txt +1 -0
- package/generator/test/unittests/test_model_base_serialization.py +53 -0
- package/package.json +33 -33
|
@@ -64,6 +64,22 @@ class BasicResource(Model):
|
|
|
64
64
|
super().__init__(*args, **kwargs)
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
class ModelWithArgsProperty(Model):
|
|
68
|
+
"""A model that has a property named 'args' to test potential conflicts with *args."""
|
|
69
|
+
|
|
70
|
+
name: str = rest_field()
|
|
71
|
+
args: list[str] = rest_field() # property named 'args' which could conflict with *args
|
|
72
|
+
|
|
73
|
+
@overload
|
|
74
|
+
def __init__(self, *, name: str, args: list[str]): ...
|
|
75
|
+
|
|
76
|
+
@overload
|
|
77
|
+
def __init__(self, mapping: Mapping[str, Any], /): ...
|
|
78
|
+
|
|
79
|
+
def __init__(self, *args, **kwargs):
|
|
80
|
+
super().__init__(*args, **kwargs)
|
|
81
|
+
|
|
82
|
+
|
|
67
83
|
class Pet(Model):
|
|
68
84
|
name: str = rest_field() # my name
|
|
69
85
|
species: str = rest_field() # my species
|
|
@@ -106,6 +122,43 @@ def test_model_and_dict_equal():
|
|
|
106
122
|
assert model.virtual_machines == model["virtualMachines"] == dict_response["virtualMachines"]
|
|
107
123
|
|
|
108
124
|
|
|
125
|
+
def test_model_with_args_property():
|
|
126
|
+
"""Test that a model with a property named 'args' works correctly."""
|
|
127
|
+
# Test initialization with keyword arguments
|
|
128
|
+
model = ModelWithArgsProperty(name="test", args=["arg1", "arg2", "arg3"])
|
|
129
|
+
assert model.name == "test"
|
|
130
|
+
assert model.args == ["arg1", "arg2", "arg3"]
|
|
131
|
+
|
|
132
|
+
# Test dict-style access
|
|
133
|
+
assert model["name"] == "test"
|
|
134
|
+
assert model["args"] == ["arg1", "arg2", "arg3"]
|
|
135
|
+
|
|
136
|
+
# Test equality with dict
|
|
137
|
+
dict_response = {"name": "test", "args": ["arg1", "arg2", "arg3"]}
|
|
138
|
+
assert model == dict_response
|
|
139
|
+
|
|
140
|
+
# Test initialization from dict (using positional argument which goes to *args)
|
|
141
|
+
model_from_dict = ModelWithArgsProperty(dict_response)
|
|
142
|
+
assert model_from_dict.name == "test"
|
|
143
|
+
assert model_from_dict.args == ["arg1", "arg2", "arg3"]
|
|
144
|
+
assert model_from_dict == model
|
|
145
|
+
|
|
146
|
+
# Test modification of the 'args' property
|
|
147
|
+
model.args = ["new_arg"]
|
|
148
|
+
assert model.args == ["new_arg"]
|
|
149
|
+
assert model["args"] == ["new_arg"]
|
|
150
|
+
|
|
151
|
+
# Test dict-style modification of 'args'
|
|
152
|
+
model["args"] = ["modified_arg1", "modified_arg2"]
|
|
153
|
+
assert model.args == ["modified_arg1", "modified_arg2"]
|
|
154
|
+
|
|
155
|
+
# Test JSON serialization roundtrip
|
|
156
|
+
json_str = json.dumps(dict(model))
|
|
157
|
+
parsed = json.loads(json_str)
|
|
158
|
+
assert parsed["name"] == "test"
|
|
159
|
+
assert parsed["args"] == ["modified_arg1", "modified_arg2"]
|
|
160
|
+
|
|
161
|
+
|
|
109
162
|
def test_json_roundtrip():
|
|
110
163
|
dict_response = {
|
|
111
164
|
"platformUpdateDomainCount": 5,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"emitter"
|
|
55
55
|
],
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@azure-tools/typespec-autorest": ">=0.
|
|
58
|
-
"@azure-tools/typespec-azure-core": ">=0.
|
|
59
|
-
"@azure-tools/typespec-azure-resource-manager": ">=0.
|
|
60
|
-
"@azure-tools/typespec-azure-rulesets": ">=0.
|
|
61
|
-
"@azure-tools/typespec-client-generator-core": ">=0.
|
|
62
|
-
"@typespec/compiler": "^1.
|
|
63
|
-
"@typespec/http": "^1.
|
|
64
|
-
"@typespec/openapi": "^1.
|
|
65
|
-
"@typespec/rest": ">=0.
|
|
66
|
-
"@typespec/versioning": ">=0.
|
|
67
|
-
"@typespec/events": ">=0.
|
|
68
|
-
"@typespec/sse": ">=0.
|
|
69
|
-
"@typespec/streams": ">=0.
|
|
70
|
-
"@typespec/xml": ">=0.
|
|
57
|
+
"@azure-tools/typespec-autorest": ">=0.64.0 <1.0.0",
|
|
58
|
+
"@azure-tools/typespec-azure-core": ">=0.64.0 <1.0.0",
|
|
59
|
+
"@azure-tools/typespec-azure-resource-manager": ">=0.64.0 <1.0.0",
|
|
60
|
+
"@azure-tools/typespec-azure-rulesets": ">=0.64.0 <1.0.0",
|
|
61
|
+
"@azure-tools/typespec-client-generator-core": ">=0.64.2 <1.0.0",
|
|
62
|
+
"@typespec/compiler": "^1.8.0",
|
|
63
|
+
"@typespec/http": "^1.8.0",
|
|
64
|
+
"@typespec/openapi": "^1.8.0",
|
|
65
|
+
"@typespec/rest": ">=0.78.0 <1.0.0",
|
|
66
|
+
"@typespec/versioning": ">=0.78.0 <1.0.0",
|
|
67
|
+
"@typespec/events": ">=0.78.0 <1.0.0",
|
|
68
|
+
"@typespec/sse": ">=0.78.0 <1.0.0",
|
|
69
|
+
"@typespec/streams": ">=0.78.0 <1.0.0",
|
|
70
|
+
"@typespec/xml": ">=0.78.0 <1.0.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"js-yaml": "~4.1.0",
|
|
@@ -77,24 +77,24 @@
|
|
|
77
77
|
"tsx": "~4.19.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@azure-tools/typespec-autorest": "~0.
|
|
81
|
-
"@azure-tools/typespec-azure-core": "~0.
|
|
82
|
-
"@azure-tools/typespec-azure-resource-manager": "~0.
|
|
83
|
-
"@azure-tools/typespec-azure-rulesets": "~0.
|
|
84
|
-
"@azure-tools/typespec-client-generator-core": "~0.
|
|
85
|
-
"@azure-tools/azure-http-specs": "0.1.0-alpha.
|
|
86
|
-
"@typespec/compiler": "^1.
|
|
87
|
-
"@typespec/http": "^1.
|
|
88
|
-
"@typespec/openapi": "^1.
|
|
89
|
-
"@typespec/rest": "~0.
|
|
90
|
-
"@typespec/versioning": "~0.
|
|
91
|
-
"@typespec/events": "~0.
|
|
92
|
-
"@typespec/spector": "0.1.0-alpha.
|
|
93
|
-
"@typespec/spec-api": "0.1.0-alpha.
|
|
94
|
-
"@typespec/sse": "~0.
|
|
95
|
-
"@typespec/streams": "~0.
|
|
96
|
-
"@typespec/xml": "~0.
|
|
97
|
-
"@typespec/http-specs": "0.1.0-alpha.
|
|
80
|
+
"@azure-tools/typespec-autorest": "~0.64.0",
|
|
81
|
+
"@azure-tools/typespec-azure-core": "~0.64.0",
|
|
82
|
+
"@azure-tools/typespec-azure-resource-manager": "~0.64.0",
|
|
83
|
+
"@azure-tools/typespec-azure-rulesets": "~0.64.0",
|
|
84
|
+
"@azure-tools/typespec-client-generator-core": "~0.64.2",
|
|
85
|
+
"@azure-tools/azure-http-specs": "0.1.0-alpha.36",
|
|
86
|
+
"@typespec/compiler": "^1.8.0",
|
|
87
|
+
"@typespec/http": "^1.8.0",
|
|
88
|
+
"@typespec/openapi": "^1.8.0",
|
|
89
|
+
"@typespec/rest": "~0.78.0",
|
|
90
|
+
"@typespec/versioning": "~0.78.0",
|
|
91
|
+
"@typespec/events": "~0.78.0",
|
|
92
|
+
"@typespec/spector": "0.1.0-alpha.22",
|
|
93
|
+
"@typespec/spec-api": "0.1.0-alpha.12",
|
|
94
|
+
"@typespec/sse": "~0.78.0",
|
|
95
|
+
"@typespec/streams": "~0.78.0",
|
|
96
|
+
"@typespec/xml": "~0.78.0",
|
|
97
|
+
"@typespec/http-specs": "0.1.0-alpha.32-dev.1",
|
|
98
98
|
"@types/js-yaml": "~4.0.5",
|
|
99
99
|
"@types/node": "~24.1.0",
|
|
100
100
|
"@types/semver": "7.5.8",
|