Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_extract_node_info_unexpected_ast_node():
with pytest.raises(UnexpectedASTNode):
_extract_node_info([SchemaNode(type="unexpected", value=None)])
def enum_value_definition(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type
"enum_value_definition" with an EnumValueDefinitionNode instance as
value (extracted from the parsing of the tree instance).
:param tree: the Tree to parse in order to extract the proper node
:type tree: Tree
:return: a SchemaNode instance of type "enum_value_definition" with an
EnumValueDefinitionNode instance as value
:rtype: SchemaNode
"""
# pylint: disable=no-self-use
return SchemaNode(
type="enum_value_definition",
value=lark_to_enum_value_definition_node(tree),
)
def value(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type "value" with a
ValueNode instance as value (extracted from the parsing of the tree
instance).
:param tree: the Tree to parse in order to extract the proper node
:type tree: Tree
:return: a SchemaNode instance of type "value" with a ValueNode
instance as value
:rtype: SchemaNode
"""
# pylint: disable=no-self-use
return SchemaNode(type="value", value=tree.children[0].value)
def argument(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type "argument" with a
ArgumentNode instance as value (extracted from the parsing of the tree
instance).
:param tree: the Tree to parse in order to extract the proper node
:type tree: Tree
:return: a SchemaNode instance of type "argument" with an ArgumentNode
instance as value
:rtype: SchemaNode
"""
# pylint: disable=no-self-use
return SchemaNode(type="argument", value=lark_to_argument_node(tree))
def operation_type_definition(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type
"operation_type_definition" with an OperationTypeDefinitionNode
instance as value (extracted from the parsing of the tree instance).
:param tree: the Tree to parse in order to extract the proper node
:type tree: Tree
:return: a SchemaNode instance of type "operation_type_definition" with
an OperationTypeDefinitionNode instance as value
:rtype: SchemaNode
"""
# pylint: disable=no-self-use
return SchemaNode(
type="operation_type_definition",
value=lark_to_operation_type_definition_node(tree),
)
def directive_locations(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type "directive_locations"
with a list of NameNode instance as value (extracted from the parsing
of the tree instance).
:param tree: the Tree to parse in order to extract the proper node
:return: a SchemaNode instance of type "directive_locations" with a
list of NameNode instance as value
"""
# pylint: disable=no-self-use
return SchemaNode(
type="directive_locations",
value=[child.value for child in tree.children],
)
def directive_location(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type "directive_location"
with a NameNode instance as value (extracted from the parsing of the
tree instance).
:param tree: the Tree to parse in order to extract the proper node
:type tree: Tree
:return: a SchemaNode instance of type "directive_location" with a
NameNode instance as value
:rtype: SchemaNode
"""
# pylint: disable=no-self-use
return SchemaNode(
type="directive_location", value=lark_to_name_node(tree)
)
def directive(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type "directive" with a
DirectiveNode instance as value (extracted from the parsing of the tree
instance).
:param tree: the Tree to parse in order to extract the proper node
:type tree: Tree
:return: a SchemaNode instance of type "directive" with a DirectiveNode
instance as value
:rtype: SchemaNode
"""
# pylint: disable=no-self-use
return SchemaNode(type="directive", value=lark_to_directive_node(tree))
def type(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type "type" with a
TypeNode instance as value (extracted from the parsing of the tree
instance).
:param tree: the Tree to parse in order to extract the proper node
:type tree: Tree
:return: a SchemaNode instance of type "type" with a TypeNode instance
as value
:rtype: SchemaNode
"""
# pylint: disable=no-self-use
return SchemaNode(type="type", value=tree.children[0].value)
def directive_definition(self, tree: "Tree") -> "SchemaNode":
"""
Creates and returns a SchemaNode instance of type
"directive_definition" with a DirectiveDefinitionNode instance as value
(extracted from the parsing of the tree instance).
:param tree: the Tree to parse in order to extract the proper node
:type tree: Tree
:return: a SchemaNode instance of type "directive_definition" with a
DirectiveDefinitionNode instance as value
:rtype: SchemaNode
"""
# pylint: disable=no-self-use
return SchemaNode(
type="directive_definition",
value=lark_to_directive_definition_node(tree),
)