diff --git a/.travis.yml b/.travis.yml index 32dd4b86..ff6b984c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,10 @@ matrix: python: 3.7 dist: xenial sudo: true # required workaround for https://github.com/travis-ci/travis-ci/issues/9815 - - env: TOXENV=pypy + - env: TOXENV=pypy2 python: pypy + - env: TOXENV=pypy + python: pypy3 - env: TOXENV=pre-commit python: 3.6 - env: TOXENV=mypy diff --git a/docs/conf.py b/docs/conf.py index 0e34c364..2d03a046 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,9 +60,9 @@ # built documents. # # The short X.Y version. -version = "0.1" +version = "2.3" # The full version, including alpha/beta/rc tags. -release = "0.1a0" +release = "2.3.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/graphql/__init__.py b/graphql/__init__.py index 902800b3..e846b04d 100644 --- a/graphql/__init__.py +++ b/graphql/__init__.py @@ -168,7 +168,7 @@ set_default_backend, ) -VERSION = (2, 2, 1, "final", 0) +VERSION = (2, 3, 0, "final", 0) __version__ = get_version(VERSION) diff --git a/graphql/backend/compiled.py b/graphql/backend/compiled.py index e3805cd1..91183f77 100644 --- a/graphql/backend/compiled.py +++ b/graphql/backend/compiled.py @@ -47,9 +47,9 @@ def _from_namespace(cls, schema, namespace): execute = namespace["execute"] # type: Callable namespace["schema"] = schema - return cls( # type: ignore + return cls( schema=schema, document_string=document_string, - document_ast=document_ast, + document_ast=document_ast, # type: ignore execute=execute, ) diff --git a/graphql/execution/executor.py b/graphql/execution/executor.py index 92da197a..6c7fa9c3 100644 --- a/graphql/execution/executor.py +++ b/graphql/execution/executor.py @@ -530,7 +530,9 @@ def complete_value( exe_context, return_type, field_asts, info, path, resolved ), lambda error: Promise.rejected( # type: ignore - GraphQLLocatedError(field_asts, original_error=error, path=path) + GraphQLLocatedError( # type: ignore + field_asts, original_error=error, path=path + ) ), ) @@ -602,8 +604,10 @@ def complete_list_value( completed_results.append(completed_item) index += 1 - return ( # type: ignore - Promise.all(completed_results) if contains_promise else completed_results + return ( + Promise.all(completed_results) # type: ignore + if contains_promise + else completed_results ) diff --git a/graphql/language/parser.py b/graphql/language/parser.py index 61571858..f9f8ea95 100644 --- a/graphql/language/parser.py +++ b/graphql/language/parser.py @@ -476,33 +476,33 @@ def parse_value_literal(parser, is_const): elif token.kind == TokenKind.INT: advance(parser) - return ast.IntValue( # type: ignore - value=token.value, loc=loc(parser, token.start) + return ast.IntValue( + value=token.value, loc=loc(parser, token.start) # type: ignore ) elif token.kind == TokenKind.FLOAT: advance(parser) - return ast.FloatValue( # type: ignore - value=token.value, loc=loc(parser, token.start) + return ast.FloatValue( + value=token.value, loc=loc(parser, token.start) # type: ignore ) elif token.kind == TokenKind.STRING: advance(parser) - return ast.StringValue( # type: ignore - value=token.value, loc=loc(parser, token.start) + return ast.StringValue( + value=token.value, loc=loc(parser, token.start) # type: ignore ) elif token.kind == TokenKind.NAME: if token.value in ("true", "false"): advance(parser) - return ast.BooleanValue( # type: ignore + return ast.BooleanValue( value=token.value == "true", loc=loc(parser, token.start) ) if token.value != "null": advance(parser) - return ast.EnumValue( # type: ignore - value=token.value, loc=loc(parser, token.start) + return ast.EnumValue( + value=token.value, loc=loc(parser, token.start) # type: ignore ) elif token.kind == TokenKind.DOLLAR: @@ -728,10 +728,10 @@ def parse_field_definition(parser): # type: (Parser) -> FieldDefinition start = parser.token.start - return ast.FieldDefinition( # type: ignore + return ast.FieldDefinition( name=parse_name(parser), arguments=parse_argument_defs(parser), - type=expect(parser, TokenKind.COLON) and parse_type(parser), + type=expect(parser, TokenKind.COLON) and parse_type(parser), # type: ignore directives=parse_directives(parser), loc=loc(parser, start), ) @@ -749,9 +749,9 @@ def parse_input_value_def(parser): # type: (Parser) -> InputValueDefinition start = parser.token.start - return ast.InputValueDefinition( # type: ignore + return ast.InputValueDefinition( name=parse_name(parser), - type=expect(parser, TokenKind.COLON) and parse_type(parser), + type=expect(parser, TokenKind.COLON) and parse_type(parser), # type: ignore default_value=parse_const_value(parser) if skip(parser, TokenKind.EQUALS) else None, @@ -780,10 +780,11 @@ def parse_union_type_definition(parser): start = parser.token.start expect_keyword(parser, "union") - return ast.UnionTypeDefinition( # type: ignore + return ast.UnionTypeDefinition( name=parse_name(parser), directives=parse_directives(parser), - types=expect(parser, TokenKind.EQUALS) and parse_union_members(parser), + types=expect(parser, TokenKind.EQUALS) # type: ignore + and parse_union_members(parser), loc=loc(parser, start), ) diff --git a/graphql/language/visitor.py b/graphql/language/visitor.py index 42b1a2c9..a3c3ff93 100644 --- a/graphql/language/visitor.py +++ b/graphql/language/visitor.py @@ -148,8 +148,8 @@ def visit(root, visitor, key_map=None): if not is_leaving: stack = Stack(in_array, index, keys, edits, stack) in_array = isinstance(node, list) - keys = ( # type: ignore - node + keys = ( + node # type: ignore if in_array else visitor_keys.get(type(node), None) or [] # type: ignore ) diff --git a/graphql/validation/rules/overlapping_fields_can_be_merged.py b/graphql/validation/rules/overlapping_fields_can_be_merged.py index f8b01e20..3e337d47 100644 --- a/graphql/validation/rules/overlapping_fields_can_be_merged.py +++ b/graphql/validation/rules/overlapping_fields_can_be_merged.py @@ -621,12 +621,15 @@ def _get_referenced_fields_and_fragment_names( if cached: return cached - fragment_type = type_from_ast( # type: ignore - context.get_schema(), fragment.type_condition + fragment_type = type_from_ast( + context.get_schema(), fragment.type_condition # type: ignore ) - return _get_fields_and_fragments_names( # type: ignore - context, cached_fields_and_fragment_names, fragment_type, fragment.selection_set + return _get_fields_and_fragments_names( + context, + cached_fields_and_fragment_names, + fragment_type, # type: ignore + fragment.selection_set, ) @@ -659,15 +662,15 @@ def _collect_fields_and_fragment_names( elif isinstance(selection, ast.InlineFragment): type_condition = selection.type_condition if type_condition: - inline_fragment_type = type_from_ast( # type: ignore - context.get_schema(), selection.type_condition + inline_fragment_type = type_from_ast( + context.get_schema(), selection.type_condition # type: ignore ) else: inline_fragment_type = parent_type # type: ignore - _collect_fields_and_fragment_names( # type: ignore + _collect_fields_and_fragment_names( context, - inline_fragment_type, + inline_fragment_type, # type: ignore selection.selection_set, ast_and_defs, fragment_names, @@ -683,8 +686,8 @@ def _subfield_conflicts( # type: (...) -> Optional[Tuple[Tuple[str, str], List[Node], List[Node]]] """Given a series of Conflicts which occurred between two sub-fields, generate a single Conflict.""" if conflicts: - return ( # type: ignore - (response_name, [conflict[0] for conflict in conflicts]), + return ( + (response_name, [conflict[0] for conflict in conflicts]), # type: ignore tuple(itertools.chain([ast1], *[conflict[1] for conflict in conflicts])), tuple(itertools.chain([ast2], *[conflict[2] for conflict in conflicts])), ) diff --git a/setup.py b/setup.py index d705d06c..b0095af5 100644 --- a/setup.py +++ b/setup.py @@ -21,14 +21,14 @@ sys.path[:] = path_copy -install_requires = ["six>=1.10.0", "promise>=2.3", "rx>=1.6,<3"] +install_requires = ["six>=1.10.0", "promise>=2.3,<3", "rx>=1.6,<2"] tests_requires = [ - "pytest>=3.3,<4.0", + "pytest==3.10.1", "pytest-django==2.9.1", "pytest-cov==2.3.1", - "coveralls", - "gevent>=1.1", + "coveralls==1.10.0", + "gevent==1.4.0", "six>=1.10.0", "pytest-benchmark==3.0.0", "pytest-mock==1.2", @@ -67,7 +67,6 @@ def run_tests(self): "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", diff --git a/tox.ini b/tox.ini index bdeeef17..84171501 100644 --- a/tox.ini +++ b/tox.ini @@ -1,26 +1,26 @@ [tox] -envlist = py{27,34,35,36,37,py},pre-commit,mypy,docs +envlist = py{27,35,36,37,py,py3},pre-commit,mypy,docs [testenv] deps = .[test] commands = - py{27,34,py}: py.test graphql tests {posargs} - py{35,36,37}: py.test graphql tests tests_py35 {posargs} + py{27,py}: py.test graphql tests {posargs} + py{35,36,37,py3}: py.test graphql tests tests_py35 {posargs} [testenv:pre-commit] -basepython=python3.6 +basepython=python3.7 deps = - pre-commit>0.12.0 + pre-commit==1.21.0 setenv = LC_CTYPE=en_US.UTF-8 commands = pre-commit {posargs:run --all-files} [testenv:mypy] -basepython=python3.6 +basepython=python3.7 deps = - mypy==0.720 + mypy==0.761 commands = mypy graphql --ignore-missing-imports