Skip to content

Commit 02ec439

Browse files
author
normanre
committed
Fixed Test-Errors
1 parent 5f35bde commit 02ec439

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

ariadne_codegen/client_generators/custom_arguments.py

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import ast
2-
import enum
32
from typing import Any, Dict, List, Optional, Tuple, Union, cast
43

54
from graphql import (
65
GraphQLEnumType,
76
GraphQLInputObjectType,
87
GraphQLInterfaceType,
8+
GraphQLList,
99
GraphQLNonNull,
1010
GraphQLObjectType,
1111
GraphQLScalarType,
1212
GraphQLUnionType,
13-
GraphQLList,
1413
)
1514

1615
from ..codegen import (
@@ -25,10 +24,10 @@
2524
generate_dict,
2625
generate_import_from,
2726
generate_keyword,
27+
generate_list_annotation,
2828
generate_name,
2929
generate_subscript,
3030
generate_tuple,
31-
generate_list_annotation,
3231
)
3332
from ..exceptions import ParsingError
3433
from ..plugins.manager import PluginManager
@@ -38,6 +37,8 @@
3837
BASE_MODEL_FILE_PATH,
3938
DICT,
4039
INPUT_SCALARS_MAP,
40+
LIST,
41+
TYPING_MODULE,
4142
UPLOAD_CLASS_NAME,
4243
)
4344
from .custom_generator_utils import get_final_type
@@ -128,7 +129,13 @@ def _accumulate_return_arguments(
128129
return_arguments_values: List[ast.expr],
129130
arg_name: str,
130131
name: str,
131-
complete_type: Union[GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLNonNull, GraphQLList],
132+
complete_type: Union[
133+
GraphQLObjectType,
134+
GraphQLInterfaceType,
135+
GraphQLUnionType,
136+
GraphQLNonNull,
137+
GraphQLList,
138+
],
132139
used_custom_scalar: Optional[str],
133140
) -> None:
134141
"""Accumulates return arguments."""
@@ -148,7 +155,13 @@ def _accumulate_return_arguments(
148155

149156
def _generate_complete_type_name(
150157
self,
151-
complete_type: Union[GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLNonNull, GraphQLList]
158+
complete_type: Union[
159+
GraphQLObjectType,
160+
GraphQLInterfaceType,
161+
GraphQLUnionType,
162+
GraphQLNonNull,
163+
GraphQLList,
164+
],
152165
) -> str:
153166
if isinstance(complete_type, GraphQLNonNull):
154167
if hasattr(complete_type, "of_type"):
@@ -225,8 +238,18 @@ def _parse_graphql_type_name(
225238
self._used_custom_scalars.append(used_custom_scalar)
226239
else:
227240
raise ParsingError(f"Incorrect argument type {name}")
228-
return generate_annotation_name(name, nullable) if not is_list else generate_list_annotation(
229-
generate_annotation_name(name, nullable=False), nullable), used_custom_scalar
241+
242+
if is_list:
243+
self._add_import(generate_import_from(names=[LIST], from_=TYPING_MODULE))
244+
245+
return (
246+
generate_annotation_name(name, nullable)
247+
if not is_list
248+
else generate_list_annotation(
249+
generate_annotation_name(name, nullable=False), nullable
250+
),
251+
used_custom_scalar,
252+
)
230253

231254
def add_custom_scalar_imports(self) -> None:
232255
"""Adds imports for custom scalars used in the schema."""

ariadne_codegen/client_generators/custom_fields.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
OPTIONAL,
4343
TYPING_MODULE,
4444
UNION,
45-
LIST,
4645
)
4746
from .custom_generator_utils import TypeCollector, get_final_type
4847
from .scalars import ScalarData
@@ -71,7 +70,7 @@ def __init__(
7170
]
7271
self._add_import(
7372
generate_import_from(
74-
[OPTIONAL, UNION, ANY, DICT, LIST],
73+
[OPTIONAL, UNION, ANY, DICT],
7574
TYPING_MODULE,
7675
)
7776
)

ariadne_codegen/client_generators/custom_operation.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
GRAPHQL_UNION_SUFFIX,
3636
OPTIONAL,
3737
TYPING_MODULE,
38-
LIST,
3938
)
4039
from .custom_generator_utils import get_final_type
4140
from .scalars import ScalarData
@@ -68,7 +67,7 @@ def __init__(
6867

6968
self._imports: List[ast.ImportFrom] = []
7069
self._type_imports: List[ast.ImportFrom] = []
71-
self._add_import(generate_import_from([OPTIONAL, ANY, DICT, LIST], TYPING_MODULE))
70+
self._add_import(generate_import_from([OPTIONAL, ANY, DICT], TYPING_MODULE))
7271
self.argument_generator = ArgumentGenerator(
7372
self.custom_scalars,
7473
self.convert_to_snake_case,

0 commit comments

Comments
 (0)