diff --git a/.travis.yml b/.travis.yml index d0a6a960..18723a45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,26 @@ language: python -sudo: false -python: -- 2.7 -# - "pypy-5.3.1" -install: -- pip install -e .[test] -- pip install flake8 -script: -- flake8 -- py.test --cov=graphql graphql tests -after_success: -- coveralls matrix: include: - - python: '3.5' - after_install: - - pip install pytest-asyncio - script: - - py.test --cov=graphql graphql tests tests_py35 - - python: '3.6' - install: - - pip install -e .[test] - - pip install pytest-asyncio mypy - script: - - py.test --cov=graphql graphql tests tests_py35 - - mypy graphql --ignore-missing-imports - - python: '2.7' - + - env: TOXENV=py27 + - env: TOXENV=py34 + python: 3.4 + - env: TOXENV=py35 + python: 3.5 + - env: TOXENV=py36 + python: 3.6 + - env: TOXENV=pypy + python: pypy-5.7.1 + - env: TOXENV=pre-commit + python: 3.6 + - env: TOXENV=mypy + python: 3.6 +install: pip install coveralls tox +script: tox +after_success: coveralls +cache: + directories: + - $HOME/.cache/pip + - $HOME/.cache/pre-commit deploy: provider: pypi user: syrusakbary diff --git a/graphql/backend/base.py b/graphql/backend/base.py index 9d3420b3..6573d3a7 100644 --- a/graphql/backend/base.py +++ b/graphql/backend/base.py @@ -4,6 +4,7 @@ from abc import ABCMeta, abstractmethod import six + # Necessary for static type checking if False: # flake8: noqa from typing import Dict, Optional, Union, Callable diff --git a/graphql/backend/cache.py b/graphql/backend/cache.py index 12696467..00680644 100644 --- a/graphql/backend/cache.py +++ b/graphql/backend/cache.py @@ -1,4 +1,5 @@ from hashlib import sha1 + from six import string_types from ..type import GraphQLSchema diff --git a/graphql/execution/tests/test_located_error.py b/graphql/execution/tests/test_located_error.py index 1676312c..26773804 100644 --- a/graphql/execution/tests/test_located_error.py +++ b/graphql/execution/tests/test_located_error.py @@ -1,12 +1,8 @@ # type: ignore # coding: utf-8 -from graphql import GraphQLField -from graphql import GraphQLObjectType -from graphql import GraphQLSchema -from graphql import GraphQLString -from graphql import execute -from graphql import parse +from graphql import (GraphQLField, GraphQLObjectType, GraphQLSchema, + GraphQLString, execute, parse) from graphql.error import GraphQLLocatedError diff --git a/graphql/execution/tests/test_variables.py b/graphql/execution/tests/test_variables.py index 63d64904..a4a1a8fe 100644 --- a/graphql/execution/tests/test_variables.py +++ b/graphql/execution/tests/test_variables.py @@ -3,7 +3,6 @@ from collections import OrderedDict from pytest import raises - from graphql.error import GraphQLError, format_error from graphql.execution import execute from graphql.language.parser import parse diff --git a/graphql/language/lexer.py b/graphql/language/lexer.py index a60bc6e2..a017dbce 100644 --- a/graphql/language/lexer.py +++ b/graphql/language/lexer.py @@ -372,7 +372,7 @@ def read_string(source, start): position += 1 if code == 92: # \ - append(body[chunk_start : position - 1]) + append(body[chunk_start: position - 1]) code = char_code_at(body, position) escaped = ESCAPED_CHAR_CODES.get(code) # type: ignore @@ -392,7 +392,7 @@ def read_string(source, start): source, position, u"Invalid character escape sequence: \\u{}.".format( - body[position + 1 : position + 5] + body[position + 1: position + 5] ), ) diff --git a/graphql/pyutils/compat.py b/graphql/pyutils/compat.py index 0012f20b..43613d74 100644 --- a/graphql/pyutils/compat.py +++ b/graphql/pyutils/compat.py @@ -240,4 +240,3 @@ def check_threads(): '(Enable the "enable-threads" flag).' ) ) - diff --git a/graphql/type/definition.py b/graphql/type/definition.py index 9099242e..ce9dffb5 100644 --- a/graphql/type/definition.py +++ b/graphql/type/definition.py @@ -626,17 +626,17 @@ class GeoPoint(GraphQLInputObjectType): """ def __init__(self, - name, # type: str - fields, # type: Union[Callable[[], Dict[str, GraphQLInputObjectField]], Dict[str, GraphQLInputObjectField]] - description=None, # type: Optional[str] - container_type=None, # type: Type[Dict[str, Any]] - ): + name, # type: str + fields, # type: Union[Callable[[], Dict[str, GraphQLInputObjectField]], Dict[str, GraphQLInputObjectField]] + description=None, # type: Optional[str] + container_type=None, # type: Type[Dict[str, Any]] + ): # type: (...) -> None assert name, "Type must be named." self.name = name self.description = description if container_type is None: - container_type = dict # type: ignore + container_type = dict # type: ignore assert callable(container_type), "container_type must be callable" self.container_type = container_type self._fields = fields @@ -755,7 +755,7 @@ class RowType(GraphQLObjectType): def __init__( self, - type, # type: Union[GraphQLList, GraphQLObjectType, GraphQLScalarType, GraphQLInputObjectType, GraphQLInterfaceType] + type, # type: Union[GraphQLList, GraphQLObjectType, GraphQLScalarType, GraphQLInputObjectType, GraphQLInterfaceType] ): # type: (...) -> None assert is_type(type) and not isinstance( diff --git a/graphql/type/tests/test_definition.py b/graphql/type/tests/test_definition.py index 0281a83f..944694ed 100644 --- a/graphql/type/tests/test_definition.py +++ b/graphql/type/tests/test_definition.py @@ -1,5 +1,4 @@ from collections import OrderedDict - from py.test import raises from graphql.type import ( diff --git a/graphql/type/tests/test_enum_type.py b/graphql/type/tests/test_enum_type.py index 9ac33ebd..989fac82 100644 --- a/graphql/type/tests/test_enum_type.py +++ b/graphql/type/tests/test_enum_type.py @@ -1,7 +1,5 @@ from collections import OrderedDict - from rx import Observable - from graphql import graphql from graphql.type import ( 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..4cba7ca2 100644 --- a/graphql/validation/rules/overlapping_fields_can_be_merged.py +++ b/graphql/validation/rules/overlapping_fields_can_be_merged.py @@ -207,7 +207,7 @@ def _find_conflicts_within_selection_set( # selection set to collect conflicts within fragments spread together. # This compares each item in the list of fragment names to every other item # in that same list (except for itself). - for other_fragment_name in fragment_names[i + 1 :]: + for other_fragment_name in fragment_names[i + 1:]: _collect_conflicts_between_fragments( context, conflicts, @@ -444,7 +444,7 @@ def _collect_conflicts_within( # (except to itself). If the list only has one item, nothing needs to # be compared. for i, field in enumerate(fields): - for other_field in fields[i + 1 :]: + for other_field in fields[i + 1:]: # within one collection is never mutually exclusive conflict = _find_conflict( context, diff --git a/tox.ini b/tox.ini index 5fd35571..fb860075 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = flake8,isort,py27,py33,py34,py35,py36,pre-commit,pypy,docs +envlist = py27,py34,py35,py36,pre-commit,pypy,mypy,docs [testenv] deps = @@ -10,7 +10,7 @@ deps = pytest-mock pytest-benchmark commands = - py{27,33,34,py}: py.test graphql tests {posargs} + py{27,34,py}: py.test graphql tests {posargs} py{35,36}: py.test graphql tests tests_py35 {posargs} [testenv:pre-commit] @@ -22,16 +22,12 @@ setenv = commands = pre-commit {posargs:run --all-files} -[testenv:flake8] -deps = flake8 -commands = flake8 - -[testenv:isort] -basepython=python3.5 +[testenv:mypy] +basepython=python3.6 deps = - isort==3.9.6 - gevent==1.1rc1 -commands = isort -rc graphql + mypy +commands = + mypy graphql --ignore-missing-imports [testenv:docs] changedir = docs