Skip to content

Commit

Permalink
refactore code
Browse files Browse the repository at this point in the history
  • Loading branch information
Minister944 committed Feb 27, 2024
1 parent ac92bd1 commit d59f729
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions ariadne_codegen/client_generators/result_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,6 @@ def generate(self) -> ast.Module:
return module

def include_model_rebuild(self, class_def: ast.ClassDef) -> bool:
class NameVisitor(ast.NodeVisitor):
def __init__(self):
self.found_name_with_quote = False

def visit_Name(self, node): # pylint: disable=C0103
if '"' in node.id:
self.found_name_with_quote = True
self.generic_visit(node)

def visit_Subscript(self, node): # pylint: disable=C0103
if isinstance(node.value, ast.Name) and node.value.id == "Literal":
return

self.generic_visit(node)

visitor = NameVisitor()
visitor.visit(class_def)
return visitor.found_name_with_quote
Expand Down Expand Up @@ -591,3 +576,19 @@ def enter_field(node: FieldNode, *_args: Any) -> FieldNode:
copied_node = deepcopy(node)
visit(copied_node, RemoveMixinVisitor())
return copied_node


class NameVisitor(ast.NodeVisitor):
def __init__(self):
self.found_name_with_quote = False

def visit_Name(self, node): # pylint: disable=C0103
if '"' in node.id:
self.found_name_with_quote = True
self.generic_visit(node)

def visit_Subscript(self, node): # pylint: disable=C0103
if isinstance(node.value, ast.Name) and node.value.id == "Literal":
return

self.generic_visit(node)

0 comments on commit d59f729

Please sign in to comment.