Skip to content

Commit

Permalink
Fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianCzajkowski committed Jun 6, 2024
1 parent 51b05c9 commit 5395a9b
Show file tree
Hide file tree
Showing 15 changed files with 3,240 additions and 3,236 deletions.
12 changes: 10 additions & 2 deletions ariadne_codegen/client_generators/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ def __init__(
self._imports: List[Union[ast.ImportFrom, ast.Import]] = []
self._add_import(
generate_import_from(
[OPTIONAL, LIST, DICT, ANY, UNION, ASYNC_ITERATOR], TYPING_MODULE
[
OPTIONAL,
LIST,
DICT,
ANY,
UNION,
ASYNC_ITERATOR,
],
TYPING_MODULE,
)
)
self._add_import(base_client_import)
Expand Down Expand Up @@ -268,7 +276,7 @@ def add_execute_custom_operation_method(self):
generators=[
generate_comp(
target="field",
iter="fields",
iter_="fields",
)
],
),
Expand Down
2 changes: 1 addition & 1 deletion ariadne_codegen/client_generators/custom_fields_typing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ast
from typing import List, Union, cast
from typing import List, cast

from graphql import (
GraphQLInterfaceType,
Expand Down
3 changes: 0 additions & 3 deletions ariadne_codegen/client_generators/custom_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@
ANY,
BASE_MODEL_FILE_PATH,
CUSTOM_FIELDS_FILE_PATH,
DICT,
INPUT_SCALARS_MAP,
OPTIONAL,
TYPE_CHECKING,
TYPING_MODULE,
UNION,
UPLOAD_CLASS_NAME,
)
from .scalars import ScalarData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ def _convert_value(
) -> Union[StringValueNode, IntValueNode, FloatValueNode, BooleanValueNode]:
if isinstance(value, str):
return StringValueNode(value=value)
elif isinstance(value, int):
if isinstance(value, int):
return IntValueNode(value=str(value))
elif isinstance(value, float):
if isinstance(value, float):
return FloatValueNode(value=str(value))
elif isinstance(value, bool):
if isinstance(value, bool):
return BooleanValueNode(value=value)
else:
raise TypeError(f"Unsupported argument type: {type(value)}")
raise TypeError(f"Unsupported argument type: {type(value)}")

def to_ast(self) -> ArgumentNode:
return ArgumentNode(name=NameNode(value=self._name), value=self._value)
Expand Down
2 changes: 1 addition & 1 deletion ariadne_codegen/client_generators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _collect_dependent_types(self, graphql_type: GraphQLObjectType) -> None:
if isinstance(subfield_type, GraphQLObjectType):
stack.append(subfield_type)
elif isinstance(subfield_type, GraphQLUnionType):
stack.extend([union_type for union_type in subfield_type.types])
stack.extend(subfield_type.types)
for interface in current_type.interfaces:
stack.append(interface)

Expand Down
4 changes: 2 additions & 2 deletions ariadne_codegen/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,12 @@ def generate_list_comp(


def generate_comp(
target: str, iter: str, ifs: Optional[List[ast.expr]] = None, is_async: int = 0
target: str, iter_: str, ifs: Optional[List[ast.expr]] = None, is_async: int = 0
) -> ast.comprehension:
"Generate comprehension"
return ast.comprehension(
target=generate_name(target),
iter=generate_name(iter),
iter=generate_name(iter_),
ifs=ifs if ifs else [],
is_async=is_async,
)
Expand Down
Loading

0 comments on commit 5395a9b

Please sign in to comment.