Skip to content

Commit

Permalink
Merge 0df49f7 into 1b2ae07
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Sep 30, 2018
2 parents 1b2ae07 + 0df49f7 commit 5b47e43
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 61 deletions.
6 changes: 4 additions & 2 deletions graphql_compiler/compiler/blocks.py
Expand Up @@ -4,8 +4,10 @@
import six

from .compiler_entities import BasicBlock, Expression, MarkerBlock
from .helpers import (FoldScopeLocation, ensure_unicode_string, safe_quoted_string,
validate_edge_direction, validate_marked_location, validate_safe_string)
from .helpers import (
FoldScopeLocation, ensure_unicode_string, safe_quoted_string, validate_edge_direction,
validate_marked_location, validate_safe_string
)


class QueryRoot(BasicBlock):
Expand Down
31 changes: 18 additions & 13 deletions graphql_compiler/compiler/compiler_frontend.py
Expand Up @@ -62,26 +62,31 @@
from graphql.error import GraphQLSyntaxError
from graphql.language.ast import Field, InlineFragment
from graphql.language.parser import parse
from graphql.type.definition import (GraphQLInterfaceType, GraphQLList, GraphQLObjectType,
GraphQLUnionType)
from graphql.type.definition import (
GraphQLInterfaceType, GraphQLList, GraphQLObjectType, GraphQLUnionType
)
from graphql.validation import validate
import six

from . import blocks, expressions
from ..exceptions import GraphQLCompilationError, GraphQLParsingError, GraphQLValidationError
from ..schema import DIRECTIVES
from .context_helpers import (has_encountered_output_source, is_in_fold_scope, is_in_optional_scope,
validate_context_for_visiting_vertex_field)
from .directive_helpers import (get_local_filter_directives, get_unique_directives,
validate_property_directives, validate_root_vertex_directives,
validate_vertex_directives,
validate_vertex_field_directive_in_context,
validate_vertex_field_directive_interactions)
from .context_helpers import (
has_encountered_output_source, is_in_fold_scope, is_in_optional_scope,
validate_context_for_visiting_vertex_field
)
from .directive_helpers import (
get_local_filter_directives, get_unique_directives, validate_property_directives,
validate_root_vertex_directives, validate_vertex_directives,
validate_vertex_field_directive_in_context, validate_vertex_field_directive_interactions
)
from .filters import process_filter_directive
from .helpers import (FoldScopeLocation, Location, get_ast_field_name, get_edge_direction_and_name,
get_field_type_from_schema, get_uniquely_named_objects_by_name,
get_vertex_field_type, invert_dict, is_vertex_field_name,
strip_non_null_from_type, validate_output_name, validate_safe_string)
from .helpers import (
FoldScopeLocation, Location, get_ast_field_name, get_edge_direction_and_name,
get_field_type_from_schema, get_uniquely_named_objects_by_name, get_vertex_field_type,
invert_dict, is_vertex_field_name, strip_non_null_from_type, validate_output_name,
validate_safe_string
)
from .metadata import LocationInfo, QueryMetadataTable


Expand Down
6 changes: 4 additions & 2 deletions graphql_compiler/compiler/directive_helpers.py
Expand Up @@ -6,8 +6,10 @@

from ..exceptions import GraphQLCompilationError
from .filters import is_filter_with_outer_scope_vertex_field_operator
from .helpers import (FilterOperationInfo, get_ast_field_name, get_ast_field_name_or_none,
get_vertex_field_type, is_vertex_field_type)
from .helpers import (
FilterOperationInfo, get_ast_field_name, get_ast_field_name_or_none, get_vertex_field_type,
is_vertex_field_type
)


ALLOWED_DUPLICATED_DIRECTIVES = frozenset({'filter'})
Expand Down
8 changes: 5 additions & 3 deletions graphql_compiler/compiler/expressions.py
Expand Up @@ -5,9 +5,11 @@
from ..exceptions import GraphQLCompilationError
from ..schema import GraphQLDate, GraphQLDateTime
from .compiler_entities import Expression
from .helpers import (STANDARD_DATE_FORMAT, STANDARD_DATETIME_FORMAT, FoldScopeLocation, Location,
ensure_unicode_string, is_graphql_type, is_vertex_field_name,
safe_quoted_string, strip_non_null_from_type, validate_safe_string)
from .helpers import (
STANDARD_DATE_FORMAT, STANDARD_DATETIME_FORMAT, FoldScopeLocation, Location,
ensure_unicode_string, is_graphql_type, is_vertex_field_name, safe_quoted_string,
strip_non_null_from_type, validate_safe_string
)


# Since MATCH uses $-prefixed keywords to indicate special values,
Expand Down
6 changes: 4 additions & 2 deletions graphql_compiler/compiler/filters.py
Expand Up @@ -7,8 +7,10 @@

from . import blocks, expressions
from ..exceptions import GraphQLCompilationError, GraphQLValidationError
from .helpers import (get_uniquely_named_objects_by_name, is_vertex_field_name,
is_vertex_field_type, strip_non_null_from_type, validate_safe_string)
from .helpers import (
get_uniquely_named_objects_by_name, is_vertex_field_name, is_vertex_field_type,
strip_non_null_from_type, validate_safe_string
)


def scalar_leaf_only(operator):
Expand Down
10 changes: 6 additions & 4 deletions graphql_compiler/compiler/ir_lowering_common.py
Expand Up @@ -2,10 +2,12 @@
"""Language-independent IR lowering and optimization functions."""
import six

from .blocks import (ConstructResult, EndOptional, Filter, Fold, MarkLocation, Recurse, Traverse,
Unfold)
from .expressions import (BinaryComposition, ContextField, ContextFieldExistence, FalseLiteral,
NullLiteral, TrueLiteral)
from .blocks import (
ConstructResult, EndOptional, Filter, Fold, MarkLocation, Recurse, Traverse, Unfold
)
from .expressions import (
BinaryComposition, ContextField, ContextFieldExistence, FalseLiteral, NullLiteral, TrueLiteral
)
from .helpers import validate_safe_string


Expand Down
12 changes: 7 additions & 5 deletions graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py
Expand Up @@ -16,11 +16,13 @@
from ...schema import GraphQLDate, GraphQLDateTime
from ..blocks import Backtrack, CoerceType, ConstructResult, Filter, MarkLocation, Traverse
from ..compiler_entities import Expression
from ..expressions import (BinaryComposition, FoldedOutputContextField, Literal, LocalField,
NullLiteral)
from ..helpers import (STANDARD_DATE_FORMAT, STANDARD_DATETIME_FORMAT, FoldScopeLocation,
get_only_element_from_collection, strip_non_null_from_type,
validate_safe_string)
from ..expressions import (
BinaryComposition, FoldedOutputContextField, Literal, LocalField, NullLiteral
)
from ..helpers import (
STANDARD_DATE_FORMAT, STANDARD_DATETIME_FORMAT, FoldScopeLocation,
get_only_element_from_collection, strip_non_null_from_type, validate_safe_string
)
from ..ir_lowering_common import extract_folds_from_ir_blocks


Expand Down
6 changes: 4 additions & 2 deletions graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
Expand Up @@ -11,8 +11,10 @@
import six

from ..blocks import Backtrack, CoerceType, MarkLocation, QueryRoot
from ..expressions import (BinaryComposition, ContextField, ContextFieldExistence, FalseLiteral,
FoldedOutputContextField, Literal, TernaryConditional, TrueLiteral)
from ..expressions import (
BinaryComposition, ContextField, ContextFieldExistence, FalseLiteral, FoldedOutputContextField,
Literal, TernaryConditional, TrueLiteral
)
from ..helpers import FoldScopeLocation
from .utils import convert_coerce_type_to_instanceof_filter

Expand Down
Expand Up @@ -4,12 +4,15 @@
import six

from ..blocks import ConstructResult, Filter, Traverse
from ..expressions import (BinaryComposition, ContextField, FoldedOutputContextField, Literal,
LocalField, OutputContextField, TernaryConditional, TrueLiteral,
UnaryTransformation, Variable)
from ..expressions import (
BinaryComposition, ContextField, FoldedOutputContextField, Literal, LocalField,
OutputContextField, TernaryConditional, TrueLiteral, UnaryTransformation, Variable
)
from ..match_query import MatchQuery, MatchStep
from .utils import (BetweenClause, CompoundMatchQuery, construct_optional_traversal_tree,
expression_list_to_conjunction, filter_edge_field_non_existence)
from .utils import (
BetweenClause, CompoundMatchQuery, construct_optional_traversal_tree,
expression_list_to_conjunction, filter_edge_field_non_existence
)


def _prune_traverse_using_omitted_locations(match_traversal, omitted_locations,
Expand Down
6 changes: 4 additions & 2 deletions graphql_compiler/compiler/ir_lowering_match/utils.py
Expand Up @@ -5,8 +5,10 @@
import six

from ..blocks import Filter
from ..expressions import (BinaryComposition, Expression, Literal, LocalField, NullLiteral,
SelectEdgeContextField, TrueLiteral, UnaryTransformation, ZeroLiteral)
from ..expressions import (
BinaryComposition, Expression, Literal, LocalField, NullLiteral, SelectEdgeContextField,
TrueLiteral, UnaryTransformation, ZeroLiteral
)
from ..helpers import Location, get_only_element_from_collection, is_vertex_field_name


Expand Down
6 changes: 4 additions & 2 deletions graphql_compiler/compiler/ir_sanity_checks.py
Expand Up @@ -3,8 +3,10 @@

from funcy.py2 import pairwise

from .blocks import (Backtrack, CoerceType, ConstructResult, Filter, Fold, MarkLocation,
OutputSource, QueryRoot, Recurse, Traverse, Unfold)
from .blocks import (
Backtrack, CoerceType, ConstructResult, Filter, Fold, MarkLocation, OutputSource, QueryRoot,
Recurse, Traverse, Unfold
)
from .ir_lowering_common import extract_folds_from_ir_blocks


Expand Down
6 changes: 4 additions & 2 deletions graphql_compiler/compiler/match_query.py
Expand Up @@ -3,8 +3,10 @@

from collections import namedtuple

from .blocks import (Backtrack, CoerceType, ConstructResult, Filter, Fold, GlobalOperationsStart,
MarkLocation, OutputSource, QueryRoot, Recurse, Traverse, Unfold)
from .blocks import (
Backtrack, CoerceType, ConstructResult, Filter, Fold, GlobalOperationsStart, MarkLocation,
OutputSource, QueryRoot, Recurse, Traverse, Unfold
)
from .ir_lowering_common import extract_folds_from_ir_blocks


Expand Down
Expand Up @@ -11,8 +11,9 @@
The workaround should fix the problem starting with OrientDB 2.2.18.
"""
from ..blocks import Filter
from ..expressions import (BinaryComposition, ContextField, ContextFieldExistence, NullLiteral,
TernaryConditional)
from ..expressions import (
BinaryComposition, ContextField, ContextFieldExistence, NullLiteral, TernaryConditional
)


def workaround_lowering_pass(ir_blocks):
Expand Down
6 changes: 4 additions & 2 deletions graphql_compiler/schema.py
Expand Up @@ -4,8 +4,10 @@
from decimal import Decimal

import arrow
from graphql import (DirectiveLocation, GraphQLArgument, GraphQLDirective, GraphQLInt, GraphQLList,
GraphQLNonNull, GraphQLScalarType, GraphQLString)
from graphql import (
DirectiveLocation, GraphQLArgument, GraphQLDirective, GraphQLInt, GraphQLList, GraphQLNonNull,
GraphQLScalarType, GraphQLString
)


# Constraints:
Expand Down
11 changes: 7 additions & 4 deletions graphql_compiler/tests/test_emit_output.py
Expand Up @@ -4,10 +4,13 @@
from graphql import GraphQLString

from ..compiler import emit_gremlin, emit_match
from ..compiler.blocks import (Backtrack, ConstructResult, Filter, GlobalOperationsStart,
MarkLocation, QueryRoot, Traverse)
from ..compiler.expressions import (BinaryComposition, ContextField, LocalField, NullLiteral,
OutputContextField, TernaryConditional, Variable)
from ..compiler.blocks import (
Backtrack, ConstructResult, Filter, GlobalOperationsStart, MarkLocation, QueryRoot, Traverse
)
from ..compiler.expressions import (
BinaryComposition, ContextField, LocalField, NullLiteral, OutputContextField,
TernaryConditional, Variable
)
from ..compiler.helpers import Location
from ..compiler.ir_lowering_common import OutputContextVertex
from ..compiler.ir_lowering_match.utils import CompoundMatchQuery, construct_where_filter_predicate
Expand Down
14 changes: 8 additions & 6 deletions graphql_compiler/tests/test_ir_lowering.py
Expand Up @@ -5,12 +5,14 @@
from graphql import GraphQLString

from ..compiler import ir_lowering_common, ir_lowering_gremlin, ir_lowering_match, ir_sanity_checks
from ..compiler.blocks import (Backtrack, CoerceType, ConstructResult, EndOptional, Filter,
MarkLocation, QueryRoot, Traverse)
from ..compiler.expressions import (BinaryComposition, ContextField, ContextFieldExistence,
FalseLiteral, Literal, LocalField, NullLiteral,
OutputContextField, TernaryConditional, TrueLiteral,
UnaryTransformation, Variable, ZeroLiteral)
from ..compiler.blocks import (
Backtrack, CoerceType, ConstructResult, EndOptional, Filter, MarkLocation, QueryRoot, Traverse
)
from ..compiler.expressions import (
BinaryComposition, ContextField, ContextFieldExistence, FalseLiteral, Literal, LocalField,
NullLiteral, OutputContextField, TernaryConditional, TrueLiteral, UnaryTransformation, Variable,
ZeroLiteral
)
from ..compiler.helpers import Location
from ..compiler.ir_lowering_common import OutputContextVertex
from ..compiler.ir_lowering_match.utils import BetweenClause, CompoundMatchQuery
Expand Down
6 changes: 4 additions & 2 deletions scripts/generate_test_sql/animals.py
Expand Up @@ -3,8 +3,10 @@

from .events import EVENT_NAMES_LIST
from .species import FOOD_LIST, SPECIES_LIST
from .utils import (create_edge_statement, create_name, create_vertex_statement,
extract_base_name_and_label, get_random_date, get_random_net_worth, get_uuid)
from .utils import (
create_edge_statement, create_name, create_vertex_statement, extract_base_name_and_label,
get_random_date, get_random_net_worth, get_uuid
)


NUM_INITIAL_ANIMALS = 20
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -9,6 +9,6 @@ max-line-length = 100

[isort]
line_length = 100
multi_line_output = 0
multi_line_output = 5
lines_after_imports = 2
force_sort_within_sections = 1

0 comments on commit 5b47e43

Please sign in to comment.