From ac3dd0ced16d448bc439ad896cd23f91296f62a8 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:15:39 -0700 Subject: [PATCH 01/11] Ignore .venv --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8cfb7608..da383fe6 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,4 @@ target/ .pyre /.vscode /type_info.json +/.venv From 75464ba56605f8bd6c3d1934ecf420d872d0b9e0 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:16:24 -0700 Subject: [PATCH 02/11] context_value -> context --- graphql/execution/tests/test_dataloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphql/execution/tests/test_dataloader.py b/graphql/execution/tests/test_dataloader.py index 88f292d1..d9c0a9b0 100644 --- a/graphql/execution/tests/test_dataloader.py +++ b/graphql/execution/tests/test_dataloader.py @@ -72,7 +72,7 @@ def batch_load_fn(self, keys): class Context(object): business_data_loader = BusinessDataLoader() - result = execute(schema, doc_ast, None, context_value=Context(), executor=executor) + result = execute(schema, doc_ast, None, context=Context(), executor=executor) assert not result.errors assert result.data == {"business1": {"id": "1"}, "business2": {"id": "2"}} assert load_calls == [["1", "2"]] @@ -161,7 +161,7 @@ class Context(object): business_data_loader = BusinessDataLoader() location_data_loader = LocationDataLoader() - result = execute(schema, doc_ast, None, context_value=Context(), executor=executor) + result = execute(schema, doc_ast, None, context=Context(), executor=executor) assert not result.errors assert result.data == { "business1": {"id": "1", "location": {"id": "location-1"}}, From cc16de23be6b7df075037897b2b2fa4537155752 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:24:24 -0700 Subject: [PATCH 03/11] variable_values -> variables --- graphql/execution/tests/test_executor.py | 2 +- graphql/execution/tests/test_executor_thread.py | 4 ++-- graphql/execution/tests/test_variables.py | 2 +- graphql/type/tests/test_enum_type.py | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/graphql/execution/tests/test_executor.py b/graphql/execution/tests/test_executor.py index b4298e8a..633ad3be 100644 --- a/graphql/execution/tests/test_executor.py +++ b/graphql/execution/tests/test_executor.py @@ -136,7 +136,7 @@ def deeper(self): schema = GraphQLSchema(query=DataType) result = execute( - schema, ast, Data(), operation_name="Example", variable_values={"size": 100} + schema, ast, Data(), operation_name="Example", variables={"size": 100} ) assert not result.errors assert result.data == expected diff --git a/graphql/execution/tests/test_executor_thread.py b/graphql/execution/tests/test_executor_thread.py index ceaf8ce8..b985a290 100644 --- a/graphql/execution/tests/test_executor_thread.py +++ b/graphql/execution/tests/test_executor_thread.py @@ -145,14 +145,14 @@ def handle_result(result): schema, ast, Data(), - variable_values={"size": 100}, + variables={"size": 100}, operation_name="Example", executor=ThreadExecutor(), ) ) handle_result( execute( - schema, ast, Data(), variable_values={"size": 100}, operation_name="Example" + schema, ast, Data(), variables={"size": 100}, operation_name="Example" ) ) diff --git a/graphql/execution/tests/test_variables.py b/graphql/execution/tests/test_variables.py index a4a1a8fe..7bc380bd 100644 --- a/graphql/execution/tests/test_variables.py +++ b/graphql/execution/tests/test_variables.py @@ -152,7 +152,7 @@ def check( ): # type: (...) -> None ast = parse(doc) - response = execute(schema, ast, variable_values=args) + response = execute(schema, ast, variables=args) if response.errors: result = { diff --git a/graphql/type/tests/test_enum_type.py b/graphql/type/tests/test_enum_type.py index 989fac82..8aaa749a 100644 --- a/graphql/type/tests/test_enum_type.py +++ b/graphql/type/tests/test_enum_type.py @@ -161,7 +161,7 @@ def test_accepts_json_string_as_enum_variable(): result = graphql( Schema, "query test($color: Color!) { colorEnum(fromEnum: $color) }", - variable_values={"color": "BLUE"}, + variables={"color": "BLUE"}, ) assert not result.errors assert result.data == {"colorEnum": "BLUE"} @@ -171,7 +171,7 @@ def test_accepts_enum_literals_as_input_arguments_to_mutations(): result = graphql( Schema, "mutation x($color: Color!) { favoriteEnum(color: $color) }", - variable_values={"color": "GREEN"}, + variables={"color": "GREEN"}, ) assert not result.errors assert result.data == {"favoriteEnum": "GREEN"} @@ -181,7 +181,7 @@ def test_accepts_enum_literals_as_input_arguments_to_subscriptions(): result = graphql( Schema, "subscription x($color: Color!) { subscribeToEnum(color: $color) }", - variable_values={"color": "GREEN"}, + variables={"color": "GREEN"}, allow_subscriptions=True, ) assert isinstance(result, Observable) @@ -196,7 +196,7 @@ def test_does_not_accept_internal_value_as_enum_variable(): result = graphql( Schema, "query test($color: Color!) { colorEnum(fromEnum: $color) }", - variable_values={"color": 2}, + variables={"color": 2}, ) assert not result.data assert ( @@ -209,7 +209,7 @@ def test_does_not_accept_string_variables_as_enum_input(): result = graphql( Schema, "query test($color: String!) { colorEnum(fromEnum: $color) }", - variable_values={"color": "BLUE"}, + variables={"color": "BLUE"}, ) assert not result.data assert ( @@ -222,7 +222,7 @@ def test_does_not_accept_internal_value_as_enum_input(): result = graphql( Schema, "query test($color: Int!) { colorEnum(fromEnum: $color) }", - variable_values={"color": 2}, + variables={"color": 2}, ) assert not result.data assert ( From fd5e460b5ed2f2e0756043ee50d070dd3a3742ba Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:25:17 -0700 Subject: [PATCH 04/11] context_value -> context --- graphql/execution/tests/test_union_interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql/execution/tests/test_union_interface.py b/graphql/execution/tests/test_union_interface.py index bd61ba30..8d1f4df5 100644 --- a/graphql/execution/tests/test_union_interface.py +++ b/graphql/execution/tests/test_union_interface.py @@ -367,7 +367,7 @@ def resolve_type(obj, info): context = {"hey"} ast = parse("""{ name, friends { name } }""") - result = execute(schema2, ast, john2, context_value=context) + result = execute(schema2, ast, john2, context=context) assert not result.errors assert result.data == {"name": "John", "friends": [{"name": "Liz"}]} From 7bdb61d78a5934df4e2759bb5ada6485a43c1b8b Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:26:41 -0700 Subject: [PATCH 05/11] root_value -> root --- graphql/execution/tests/test_subscribe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql/execution/tests/test_subscribe.py b/graphql/execution/tests/test_subscribe.py index 2fa039c3..96a31133 100644 --- a/graphql/execution/tests/test_subscribe.py +++ b/graphql/execution/tests/test_subscribe.py @@ -183,7 +183,7 @@ def test_accepts_an_object_with_named_properties_as_arguments(): } """ ) - result = subscribe(email_schema, document, root_value=None) + result = subscribe(email_schema, document, root=None) assert isinstance(result, Observable) From 8b650d9522a4a7dcb77c06a2329631f5eecb25a1 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:28:41 -0700 Subject: [PATCH 06/11] variable_values -> variables --- tests/starwars/test_query.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/starwars/test_query.py b/tests/starwars/test_query.py index 5e3c2cd0..237b8aae 100644 --- a/tests/starwars/test_query.py +++ b/tests/starwars/test_query.py @@ -126,7 +126,7 @@ def test_fetch_some_id_query(): """ params = {"someId": "1000"} expected = {"human": {"name": "Luke Skywalker"}} - result = graphql(StarWarsSchema, query, variable_values=params) + result = graphql(StarWarsSchema, query, variables=params) assert not result.errors assert result.data == expected @@ -141,7 +141,7 @@ def test_fetch_some_id_query2(): """ params = {"someId": "1002"} expected = {"human": {"name": "Han Solo"}} - result = graphql(StarWarsSchema, query, variable_values=params) + result = graphql(StarWarsSchema, query, variables=params) assert not result.errors assert result.data == expected @@ -156,7 +156,7 @@ def test_invalid_id_query(): """ params = {"id": "not a valid id"} expected = {"human": None} - result = graphql(StarWarsSchema, query, variable_values=params) + result = graphql(StarWarsSchema, query, variables=params) assert not result.errors assert result.data == expected From 7d5a0a92754982742ec981a688cb2bfd10a445fd Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:42:29 -0700 Subject: [PATCH 07/11] Update pypy, py37 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e1d1aafc..a075f4c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,10 @@ matrix: python: 3.5 - env: TOXENV=py36 python: 3.6 - # - env: TOXENV=py37 - # python: 3.7 + - env: TOXENV=py37 + python: 3.7 - env: TOXENV=pypy - python: pypy-5.7.1 + python: pypy-6.0 - env: TOXENV=pre-commit python: 3.6 - env: TOXENV=mypy From 89a41978bd41f49ae82b2206233033cd5c53574b Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:45:15 -0700 Subject: [PATCH 08/11] Updated dependencies for Python3.7 to work --- setup.py | 4 ++-- tox.ini | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 9d9dea61..3ed71c3e 100644 --- a/setup.py +++ b/setup.py @@ -24,11 +24,11 @@ install_requires = ["six>=1.10.0", "promise>=2.1", "rx>=1.6.0"] tests_requires = [ - "pytest==3.0.2", + "pytest~=3.8.1", "pytest-django==2.9.1", "pytest-cov==2.3.1", "coveralls", - "gevent==1.1rc1", + "gevent~=1.3.6", "six>=1.10.0", "pytest-benchmark==3.0.0", "pytest-mock==1.2", diff --git a/tox.ini b/tox.ini index 637f79ca..ba0d01d9 100644 --- a/tox.ini +++ b/tox.ini @@ -3,8 +3,8 @@ envlist = py27,py34,py35,py36,py37,pre-commit,pypy,mypy,docs [testenv] deps = - pytest>=2.7.2 - gevent==1.1rc1 + pytest>=3.8.1 + gevent~=1.3.6 promise>=2.0 six>=1.10.0 pytest-mock From 6e6e0b36dfc5bd7369b418b01825e928188a577f Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:50:22 -0700 Subject: [PATCH 09/11] Trying to fix pypy --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a075f4c7..ff19929b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: - env: TOXENV=py37 python: 3.7 - env: TOXENV=pypy - python: pypy-6.0 + python: pypy-5.7.1 - env: TOXENV=pre-commit python: 3.6 - env: TOXENV=mypy From eb848186ef0727ecf2bc222529e76fea6fae4cb2 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 14:52:36 -0700 Subject: [PATCH 10/11] travis doesnt support 3.7 yet --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff19929b..4860428d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,8 @@ matrix: python: 3.5 - env: TOXENV=py36 python: 3.6 - - env: TOXENV=py37 - python: 3.7 +# - env: TOXENV=py37 +# python: 3.7 - env: TOXENV=pypy python: pypy-5.7.1 - env: TOXENV=pre-commit From 126dd446e068d1bbbf2bee367dc3253aa2ee7163 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sun, 30 Sep 2018 15:01:36 -0700 Subject: [PATCH 11/11] pre-commit - black --- graphql/execution/tests/test_executor_thread.py | 4 +--- graphql/execution/utils.py | 8 ++++++-- graphql/utils/type_info.py | 8 ++++++-- .../validation/rules/overlapping_fields_can_be_merged.py | 4 +++- graphql/validation/validation.py | 8 ++++++-- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/graphql/execution/tests/test_executor_thread.py b/graphql/execution/tests/test_executor_thread.py index b985a290..c09540fa 100644 --- a/graphql/execution/tests/test_executor_thread.py +++ b/graphql/execution/tests/test_executor_thread.py @@ -151,9 +151,7 @@ def handle_result(result): ) ) handle_result( - execute( - schema, ast, Data(), variables={"size": 100}, operation_name="Example" - ) + execute(schema, ast, Data(), variables={"size": 100}, operation_name="Example") ) diff --git a/graphql/execution/utils.py b/graphql/execution/utils.py index b1e7ff25..d4fe4f7a 100644 --- a/graphql/execution/utils.py +++ b/graphql/execution/utils.py @@ -121,11 +121,15 @@ def __init__( self.variable_values = variable_values self.errors = errors self.context_value = context_value - self.argument_values_cache = {} # type: Dict[Tuple[GraphQLField, Field], Dict[str, Any]] + self.argument_values_cache = ( + {} + ) # type: Dict[Tuple[GraphQLField, Field], Dict[str, Any]] self.executor = executor self.middleware = middleware self.allow_subscriptions = allow_subscriptions - self._subfields_cache = {} # type: Dict[Tuple[GraphQLObjectType, Tuple[Field, ...]], DefaultOrderedDict] + self._subfields_cache = ( + {} + ) # type: Dict[Tuple[GraphQLObjectType, Tuple[Field, ...]], DefaultOrderedDict] def get_field_resolver(self, field_resolver): # type: (Callable) -> Callable diff --git a/graphql/utils/type_info.py b/graphql/utils/type_info.py index 76433eb6..f3862f30 100644 --- a/graphql/utils/type_info.py +++ b/graphql/utils/type_info.py @@ -60,8 +60,12 @@ def __init__(self, schema, get_field_def_fn=get_field_def): # type: (GraphQLSchema, Callable) -> None self._schema = schema self._type_stack = [] # type: List[Optional[GraphQLType]] - self._parent_type_stack = [] # type: List[Union[GraphQLInterfaceType, GraphQLObjectType, None]] - self._input_type_stack = [] # type: List[Optional[Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType, None]]] + self._parent_type_stack = ( + [] + ) # type: List[Union[GraphQLInterfaceType, GraphQLObjectType, None]] + self._input_type_stack = ( + [] + ) # type: List[Optional[Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType, None]]] self._field_def_stack = [] # type: List[Optional[GraphQLField]] self._directive = None # type: Optional[GraphQLDirective] self._argument = None # type: Optional[GraphQLArgument] diff --git a/graphql/validation/rules/overlapping_fields_can_be_merged.py b/graphql/validation/rules/overlapping_fields_can_be_merged.py index 8506e2cd..08f40f1b 100644 --- a/graphql/validation/rules/overlapping_fields_can_be_merged.py +++ b/graphql/validation/rules/overlapping_fields_can_be_merged.py @@ -47,7 +47,9 @@ def __init__(self, context): # A cache for the "field map" and list of fragment names found in any given # selection set. Selection sets may be asked for this information multiple # times, so this improves the performance of this validator. - self._cached_fields_and_fragment_names = {} # type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]] + self._cached_fields_and_fragment_names = ( + {} + ) # type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]] def leave_SelectionSet( self, diff --git a/graphql/validation/validation.py b/graphql/validation/validation.py index ed647742..ed6c520b 100644 --- a/graphql/validation/validation.py +++ b/graphql/validation/validation.py @@ -86,9 +86,13 @@ def __init__(self, schema, ast, type_info): self._errors = [] # type: List[GraphQLError] self._fragments = None # type: Optional[Dict[str, FragmentDefinition]] self._fragment_spreads = {} # type: Dict[Node, List[FragmentSpread]] - self._recursively_referenced_fragments = {} # type: Dict[OperationDefinition, List[FragmentSpread]] + self._recursively_referenced_fragments = ( + {} + ) # type: Dict[OperationDefinition, List[FragmentSpread]] self._variable_usages = {} # type: Dict[Node, List[VariableUsage]] - self._recursive_variable_usages = {} # type: Dict[OperationDefinition, List[VariableUsage]] + self._recursive_variable_usages = ( + {} + ) # type: Dict[OperationDefinition, List[VariableUsage]] def report_error(self, error): self._errors.append(error)