Skip to content

Commit 56b8773

Browse files
committed
fix: Regression on Any types
1 parent ebda606 commit 56b8773

23 files changed

+45
-47
lines changed

end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -35,7 +35,7 @@ def _get_kwargs(
3535

3636
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3737
if response.status_code == HTTPStatus.OK:
38-
response_200 = None
38+
response_200 = cast(Any, None)
3939
return response_200
4040
if client.raise_on_unexpected_status:
4141
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -35,7 +35,7 @@ def _get_kwargs(
3535

3636
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3737
if response.status_code == HTTPStatus.OK:
38-
response_200 = None
38+
response_200 = cast(Any, None)
3939
return response_200
4040
if client.raise_on_unexpected_status:
4141
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -54,7 +54,7 @@ def _get_kwargs(
5454

5555
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
5656
if response.status_code == HTTPStatus.OK:
57-
response_200 = None
57+
response_200 = cast(Any, None)
5858
return response_200
5959
if client.raise_on_unexpected_status:
6060
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from http import HTTPStatus
3-
from typing import Any, Dict, Optional, Union
3+
from typing import Any, Dict, Optional, Union, cast
44

55
import httpx
66

@@ -59,7 +59,7 @@ def _get_kwargs(
5959

6060
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
6161
if response.status_code == HTTPStatus.OK:
62-
response_200 = None
62+
response_200 = cast(Any, None)
6363
return response_200
6464
if client.raise_on_unexpected_status:
6565
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -45,7 +45,7 @@ def _get_kwargs(
4545

4646
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
4747
if response.status_code == HTTPStatus.OK:
48-
response_200 = None
48+
response_200 = cast(Any, None)
4949
return response_200
5050
if client.raise_on_unexpected_status:
5151
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -36,7 +36,7 @@ def _get_kwargs(
3636

3737
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3838
if response.status_code == HTTPStatus.OK:
39-
response_200 = None
39+
response_200 = cast(Any, None)
4040
return response_200
4141
if client.raise_on_unexpected_status:
4242
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -36,7 +36,7 @@ def _get_kwargs(
3636

3737
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3838
if response.status_code == HTTPStatus.OK:
39-
response_200 = None
39+
response_200 = cast(Any, None)
4040
return response_200
4141
if client.raise_on_unexpected_status:
4242
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -44,7 +44,7 @@ def _get_kwargs(
4444

4545
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
4646
if response.status_code == HTTPStatus.OK:
47-
response_200 = None
47+
response_200 = cast(Any, None)
4848
return response_200
4949
if client.raise_on_unexpected_status:
5050
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -34,7 +34,7 @@ def _get_kwargs(
3434

3535
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3636
if response.status_code == HTTPStatus.OK:
37-
response_200 = None
37+
response_200 = cast(Any, None)
3838
return response_200
3939
if client.raise_on_unexpected_status:
4040
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -28,7 +28,7 @@ def _get_kwargs(
2828

2929
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3030
if response.status_code == HTTPStatus.OK:
31-
response_200 = None
31+
response_200 = cast(Any, None)
3232
return response_200
3333
if client.raise_on_unexpected_status:
3434
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -34,7 +34,7 @@ def _get_kwargs(
3434

3535
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
3636
if response.status_code == HTTPStatus.OK:
37-
response_200 = None
37+
response_200 = cast(Any, response.json())
3838
return response_200
3939
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
4040
response_422 = HTTPValidationError.from_dict(response.json())

end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from http import HTTPStatus
3-
from typing import Any, Dict, List, Optional, Union
3+
from typing import Any, Dict, List, Optional, Union, cast
44

55
import httpx
66
from dateutil.parser import isoparse
@@ -101,7 +101,7 @@ def _get_kwargs(
101101

102102
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
103103
if response.status_code == HTTPStatus.OK:
104-
response_200 = None
104+
response_200 = cast(Any, response.json())
105105
return response_200
106106
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
107107
response_422 = HTTPValidationError.from_dict(response.json())

end_to_end_tests/golden-record/my_test_api_client/api/tests/int_enum_tests_int_enum_post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -39,7 +39,7 @@ def _get_kwargs(
3939

4040
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
4141
if response.status_code == HTTPStatus.OK:
42-
response_200 = None
42+
response_200 = cast(Any, response.json())
4343
return response_200
4444
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
4545
response_422 = HTTPValidationError.from_dict(response.json())

end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -34,7 +34,7 @@ def _get_kwargs(
3434

3535
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
3636
if response.status_code == HTTPStatus.OK:
37-
response_200 = None
37+
response_200 = cast(Any, response.json())
3838
return response_200
3939
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
4040
response_422 = HTTPValidationError.from_dict(response.json())

end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -28,7 +28,7 @@ def _get_kwargs(
2828

2929
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3030
if response.status_code == HTTPStatus.OK:
31-
response_200 = None
31+
response_200 = cast(Any, response.json())
3232
return response_200
3333
if client.raise_on_unexpected_status:
3434
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -31,7 +31,7 @@ def _get_kwargs(
3131

3232
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3333
if response.status_code == HTTPStatus.OK:
34-
response_200 = None
34+
response_200 = cast(Any, response.json())
3535
return response_200
3636
if client.raise_on_unexpected_status:
3737
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -31,7 +31,7 @@ def _get_kwargs(
3131

3232
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3333
if response.status_code == HTTPStatus.OK:
34-
response_200 = None
34+
response_200 = cast(Any, response.json())
3535
return response_200
3636
if client.raise_on_unexpected_status:
3737
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -31,10 +31,10 @@ def _get_kwargs(
3131

3232
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3333
if response.status_code == HTTPStatus.OK:
34-
response_200 = None
34+
response_200 = cast(Any, response.json())
3535
return response_200
3636
if response.status_code == HTTPStatus.UNAUTHORIZED:
37-
response_401 = None
37+
response_401 = cast(Any, None)
3838
return response_401
3939
if client.raise_on_unexpected_status:
4040
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -28,7 +28,7 @@ def _get_kwargs(
2828

2929
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3030
if response.status_code == HTTPStatus.OK:
31-
response_200 = None
31+
response_200 = cast(Any, response.json())
3232
return response_200
3333
if client.raise_on_unexpected_status:
3434
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional, Union
2+
from typing import Any, Dict, Optional, Union, cast
33

44
import httpx
55

@@ -34,7 +34,7 @@ def _get_kwargs(
3434

3535
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
3636
if response.status_code == HTTPStatus.OK:
37-
response_200 = None
37+
response_200 = cast(Any, response.json())
3838
return response_200
3939
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
4040
response_422 = HTTPValidationError.from_dict(response.json())

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, List, Optional, Union
2+
from typing import Any, Dict, List, Optional, Union, cast
33

44
import httpx
55

@@ -37,7 +37,7 @@ def _get_kwargs(
3737

3838
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Any, HTTPValidationError]]:
3939
if response.status_code == HTTPStatus.OK:
40-
response_200 = None
40+
response_200 = cast(Any, response.json())
4141
return response_200
4242
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
4343
response_422 = HTTPValidationError.from_dict(response.json())

end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Optional, cast
33

44
import httpx
55

@@ -35,7 +35,7 @@ def _get_kwargs(
3535

3636
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
3737
if response.status_code == HTTPStatus.OK:
38-
response_200 = None
38+
response_200 = cast(Any, None)
3939
return response_200
4040
if client.raise_on_unexpected_status:
4141
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")

openapi_python_client/templates/endpoint_module.py.jinja

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ def _parse_response(*, client: Client, response: httpx.Response) -> Optional[{{
6565
{% import "property_templates/" + response.prop.template as prop_template %}
6666
{% if prop_template.construct %}
6767
{{ prop_template.construct(response.prop, response.source) | indent(8) }}
68-
{% elif response.prop.get_type_string() == "Any" %}
69-
{{ response.prop.python_name }} = None
7068
{% else %}
7169
{{ response.prop.python_name }} = cast({{ response.prop.get_type_string() }}, {{ response.source }})
7270
{% endif %}

0 commit comments

Comments
 (0)