Skip to content

Commit 9c4f39b

Browse files
committed
misc fixes
1 parent c506aa0 commit 9c4f39b

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

end_to_end_tests/functional_tests/generated_code_execution/test_arrays.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, ForwardRef, List, Union
1+
from typing import Any, ForwardRef, Union
22

33
from end_to_end_tests.functional_tests.helpers import (
44
assert_model_decode_encode,
@@ -65,9 +65,9 @@ def test_array_of_object(self, ModelWithArrayOfObjects, SimpleObject):
6565
)
6666

6767
def test_type_hints(self, ModelWithArrayOfAny, ModelWithArrayOfInts, ModelWithArrayOfObjects, Unset):
68-
assert_model_property_type_hint(ModelWithArrayOfAny, "array_prop", Union[List[Any], Unset])
69-
assert_model_property_type_hint(ModelWithArrayOfInts, "array_prop", Union[List[int], Unset])
70-
assert_model_property_type_hint(ModelWithArrayOfObjects, "array_prop", Union[List[ForwardRef("SimpleObject")], Unset])
68+
assert_model_property_type_hint(ModelWithArrayOfAny, "array_prop", Union[list[Any], Unset])
69+
assert_model_property_type_hint(ModelWithArrayOfInts, "array_prop", Union[list[int], Unset])
70+
assert_model_property_type_hint(ModelWithArrayOfObjects, "array_prop", Union[list["SimpleObject"], Unset])
7171

7272

7373
@with_generated_client_fixture(
@@ -133,16 +133,16 @@ def test_prefix_items_and_regular_items(self, ModelWithMixedItems, SimpleObject)
133133
)
134134

135135
def test_type_hints(self, ModelWithSinglePrefixItem, ModelWithPrefixItems, ModelWithMixedItems, Unset):
136-
assert_model_property_type_hint(ModelWithSinglePrefixItem, "array_prop", Union[List[str], Unset])
136+
assert_model_property_type_hint(ModelWithSinglePrefixItem, "array_prop", Union[list[str], Unset])
137137
assert_model_property_type_hint(
138138
ModelWithPrefixItems,
139139
"array_prop",
140-
Union[List[Union[ForwardRef("SimpleObject"), str]], Unset],
140+
Union[list[Union[ForwardRef("SimpleObject"), str]], Unset],
141141
)
142142
assert_model_property_type_hint(
143143
ModelWithMixedItems,
144144
"array_prop",
145-
Union[List[Union[ForwardRef("SimpleObject"), str]], Unset],
145+
Union[list[Union[ForwardRef("SimpleObject"), str]], Unset],
146146
)
147147
# Note, this test is asserting the current behavior which, due to limitations of the implementation
148148
# (see: https://github.com/openapi-generators/openapi-python-client/pull/1130), is not really doing

end_to_end_tests/functional_tests/generated_code_execution/test_docstrings.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List
1+
from typing import Any
22

33
from end_to_end_tests.functional_tests.helpers import (
44
with_generated_code_import,
@@ -7,12 +7,12 @@
77

88

99
class DocstringParser:
10-
lines: List[str]
10+
lines: list[str]
1111

1212
def __init__(self, item: Any):
1313
self.lines = [line.lstrip() for line in item.__doc__.split("\n")]
1414

15-
def get_section(self, header_line: str) -> List[str]:
15+
def get_section(self, header_line: str) -> list[str]:
1616
lines = self.lines[self.lines.index(header_line)+1:]
1717
return lines[0:lines.index("")]
1818

end_to_end_tests/functional_tests/helpers.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, Dict
22
import re
3-
from typing import List, Optional
3+
from typing import Optional
44

55
from click.testing import Result
66
import pytest
@@ -12,7 +12,7 @@ def with_generated_client_fixture(
1212
openapi_spec: str,
1313
name: str="generated_client",
1414
config: str="",
15-
extra_args: List[str] = [],
15+
extra_args: list[str] = [],
1616
):
1717
"""Decorator to apply to a test class to create a fixture inside it called 'generated_client'.
1818
@@ -79,7 +79,7 @@ def assert_model_property_type_hint(model_class: Any, name: str, expected_type_h
7979

8080
def inline_spec_should_fail(
8181
openapi_spec: str,
82-
extra_args: List[str] = [],
82+
extra_args: list[str] = [],
8383
config: str = "",
8484
filename_suffix: str = "",
8585
add_missing_sections = True,
@@ -122,7 +122,7 @@ def __init__(self, generated_client: GeneratedClientContext) -> None:
122122
assert "Warning(s) encountered while generating" in output
123123
self.by_schema = {}
124124
self.output = output
125-
bad_schema_regex = "Unable to (parse|process) schema /components/schemas/(\w*)"
125+
bad_schema_regex = "Unable to (parse|process) schema /components/schemas/(\\w*)"
126126
last_name = ""
127127
while True:
128128
if not (match := re.search(bad_schema_regex, output)):

0 commit comments

Comments
 (0)