Merge branch 'master' of github.com:dan98765/graphene into pre_commit_runs_as_part_of_continuous_integration

This commit is contained in:
Daniel Gallagher 2018-06-08 21:52:34 -07:00
commit 6116901ab6
45 changed files with 79 additions and 70 deletions

View File

@ -11,4 +11,3 @@ trim_trailing_whitespace = true
[*.{py,rst,ini}] [*.{py,rst,ini}]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4

2
.isort.cfg Normal file
View File

@ -0,0 +1,2 @@
[settings]
known_third_party = aniso8601,graphql,graphql_relay,promise,pytest,pytz,pyutils,setuptools,six,snapshottest,sphinx_graphene_theme

View File

@ -1,5 +1,6 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks - repo: git://github.com/pre-commit/pre-commit-hooks
sha: v0.8.0 rev: v1.2.3
hooks: hooks:
- id: autopep8-wrapper - id: autopep8-wrapper
args: args:
@ -15,3 +16,11 @@
- id: pretty-format-json - id: pretty-format-json
args: args:
- --autofix - --autofix
- repo: https://github.com/asottile/seed-isort-config
rev: v1.0.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.4
hooks:
- id: isort

View File

@ -1,4 +1,5 @@
import os import os
import sphinx_graphene_theme
on_rtd = os.environ.get('READTHEDOCS', None) == 'True' on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
@ -136,7 +137,6 @@ todo_include_todos = True
# html_theme = 'alabaster' # html_theme = 'alabaster'
# if on_rtd: # if on_rtd:
# html_theme = 'sphinx_rtd_theme' # html_theme = 'sphinx_rtd_theme'
import sphinx_graphene_theme
html_theme = "sphinx_graphene_theme" html_theme = "sphinx_graphene_theme"

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals
from snapshottest import Snapshot from snapshottest import Snapshot
snapshots = Snapshot() snapshots = Snapshot()
snapshots['test_hero_name_query 1'] = { snapshots['test_hero_name_query 1'] = {

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals
from snapshottest import Snapshot from snapshottest import Snapshot
snapshots = Snapshot() snapshots = Snapshot()
snapshots['test_correct_fetch_first_ship_rebels 1'] = { snapshots['test_correct_fetch_first_ship_rebels 1'] = {

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals
from snapshottest import Snapshot from snapshottest import Snapshot
snapshots = Snapshot() snapshots = Snapshot()
snapshots['test_mutations 1'] = { snapshots['test_mutations 1'] = {

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals
from snapshottest import Snapshot from snapshottest import Snapshot
snapshots = Snapshot() snapshots = Snapshot()
snapshots['test_correctly_fetches_id_name_rebels 1'] = { snapshots['test_correctly_fetches_id_name_rebels 1'] = {

View File

@ -35,7 +35,7 @@ from .utils.resolve_only_args import resolve_only_args
from .utils.module_loading import lazy_import from .utils.module_loading import lazy_import
VERSION = (2, 1, 0, 'final', 0) VERSION = (2, 1, 1, 'final', 0)
__version__ = get_version(VERSION) __version__ = get_version(VERSION)

View File

@ -1,4 +1,5 @@
from __future__ import absolute_import from __future__ import absolute_import
import six import six
try: try:

View File

@ -4,11 +4,11 @@ Back port of Python 3.3's function signature tools from the inspect module,
modified to be compatible with Python 2.7 and 3.2+. modified to be compatible with Python 2.7 and 3.2+.
""" """
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import itertools
import functools import functools
import itertools
import re import re
import types import types
from collections import OrderedDict from collections import OrderedDict
__version__ = "0.4" __version__ = "0.4"

View File

@ -1,6 +1,7 @@
import pytest import pytest
from ...types import Argument, Field, Int, List, NonNull, ObjectType, String, Schema from ...types import (Argument, Field, Int, List, NonNull, ObjectType, Schema,
String)
from ..connection import Connection, ConnectionField, PageInfo from ..connection import Connection, ConnectionField, PageInfo
from ..node import Node from ..node import Node

View File

@ -1,5 +1,4 @@
import pytest import pytest
from promise import Promise from promise import Promise
from ...types import (ID, Argument, Field, InputField, InputObjectType, from ...types import (ID, Argument, Field, InputField, InputObjectType,

View File

@ -1,9 +1,10 @@
# https://github.com/graphql-python/graphene/issues/425 # https://github.com/graphql-python/graphene/issues/425
# Adapted for Graphene 2.0 # Adapted for Graphene 2.0
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
from graphene.types.inputobjecttype import InputObjectType, InputObjectTypeOptions
from graphene.types.enum import Enum, EnumOptions from graphene.types.enum import Enum, EnumOptions
from graphene.types.inputobjecttype import (InputObjectType,
InputObjectTypeOptions)
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
# ObjectType # ObjectType

View File

@ -1,5 +1,5 @@
from ..utils.subclass_with_meta import SubclassWithMeta
from ..utils.deprecated import warn_deprecation from ..utils.deprecated import warn_deprecation
from ..utils.subclass_with_meta import SubclassWithMeta
class AbstractType(SubclassWithMeta): class AbstractType(SubclassWithMeta):

View File

@ -2,8 +2,8 @@ from __future__ import absolute_import
import datetime import datetime
from aniso8601 import parse_date, parse_datetime, parse_time
from graphql.language import ast from graphql.language import ast
from aniso8601 import parse_datetime, parse_date, parse_time
from .scalars import Scalar from .scalars import Scalar

View File

@ -1,4 +1,5 @@
import inspect import inspect
from functools import partial
from .mountedtype import MountedType from .mountedtype import MountedType
@ -11,7 +12,7 @@ class Dynamic(MountedType):
def __init__(self, type, with_schema=False, _creation_counter=None): def __init__(self, type, with_schema=False, _creation_counter=None):
super(Dynamic, self).__init__(_creation_counter=_creation_counter) super(Dynamic, self).__init__(_creation_counter=_creation_counter)
assert inspect.isfunction(type) assert inspect.isfunction(type) or isinstance(type, partial)
self.type = type self.type = type
self.with_schema = with_schema self.with_schema = with_schema

View File

@ -4,11 +4,10 @@ import six
from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta
from ..pyutils.compat import Enum as PyEnum
from .base import BaseOptions, BaseType from .base import BaseOptions, BaseType
from .unmountedtype import UnmountedType from .unmountedtype import UnmountedType
from ..pyutils.compat import Enum as PyEnum
def eq_enum(self, other): def eq_enum(self, other):
if isinstance(other, self.__class__): if isinstance(other, self.__class__):

View File

@ -1,9 +1,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from graphene.types.scalars import MAX_INT, MIN_INT
from graphql.language.ast import (BooleanValue, FloatValue, IntValue, from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
ListValue, ObjectValue, StringValue) ListValue, ObjectValue, StringValue)
from graphene.types.scalars import MAX_INT, MIN_INT
from .scalars import Scalar from .scalars import Scalar

View File

@ -1,12 +1,11 @@
from collections import OrderedDict from collections import OrderedDict
from ..utils.deprecated import warn_deprecation
from ..utils.get_unbound_function import get_unbound_function from ..utils.get_unbound_function import get_unbound_function
from ..utils.props import props from ..utils.props import props
from .field import Field from .field import Field
from .objecttype import ObjectType, ObjectTypeOptions from .objecttype import ObjectType, ObjectTypeOptions
from .utils import yank_fields_from_attrs from .utils import yank_fields_from_attrs
from ..utils.deprecated import warn_deprecation
# For static type checking with Mypy # For static type checking with Mypy
MYPY = False MYPY = False

View File

@ -1,5 +1,4 @@
import six import six
from graphql.language.ast import (BooleanValue, FloatValue, IntValue, from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
StringValue) StringValue)

View File

@ -1,6 +1,6 @@
import inspect import inspect
from graphql import GraphQLSchema, graphql, is_type, GraphQLObjectType from graphql import GraphQLObjectType, GraphQLSchema, graphql, is_type
from graphql.type.directives import (GraphQLDirective, GraphQLIncludeDirective, from graphql.type.directives import (GraphQLDirective, GraphQLIncludeDirective,
GraphQLSkipDirective) GraphQLSkipDirective)
from graphql.type.introspection import IntrospectionSchema from graphql.type.introspection import IntrospectionSchema

View File

@ -1,10 +1,10 @@
import pytest import pytest
from .. import abstracttype
from ..abstracttype import AbstractType
from ..field import Field
from ..objecttype import ObjectType from ..objecttype import ObjectType
from ..unmountedtype import UnmountedType from ..unmountedtype import UnmountedType
from ..abstracttype import AbstractType
from .. import abstracttype
from ..field import Field
class MyType(ObjectType): class MyType(ObjectType):

View File

@ -1,6 +1,6 @@
import pytest import pytest
from ..base import BaseType, BaseOptions from ..base import BaseOptions, BaseType
class CustomOptions(BaseOptions): class CustomOptions(BaseOptions):

View File

@ -1,10 +1,9 @@
import datetime import datetime
import pytz import pytz
from graphql import GraphQLError from graphql import GraphQLError
from ..datetime import DateTime, Date, Time from ..datetime import Date, DateTime, Time
from ..objecttype import ObjectType from ..objecttype import ObjectType
from ..schema import Schema from ..schema import Schema

View File

@ -1,3 +1,5 @@
from functools import partial
from ..dynamic import Dynamic from ..dynamic import Dynamic
from ..scalars import String from ..scalars import String
from ..structures import List, NonNull from ..structures import List, NonNull
@ -25,3 +27,11 @@ def test_list_non_null():
dynamic = Dynamic(lambda: List(NonNull(String))) dynamic = Dynamic(lambda: List(NonNull(String)))
assert dynamic.get_type().of_type.of_type == String assert dynamic.get_type().of_type.of_type == String
assert str(dynamic.get_type()) == '[String!]' assert str(dynamic.get_type()) == '[String!]'
def test_partial():
def __type(_type):
return _type
dynamic = Dynamic(partial(__type, String))
assert dynamic.get_type() == String
assert str(dynamic.get_type()) == 'String'

View File

@ -1,10 +1,10 @@
import six import six
from ..schema import Schema, ObjectType
from ..argument import Argument from ..argument import Argument
from ..enum import Enum, PyEnum from ..enum import Enum, PyEnum
from ..field import Field from ..field import Field
from ..inputfield import InputField from ..inputfield import InputField
from ..schema import ObjectType, Schema
def test_enum_construction(): def test_enum_construction():

View File

@ -4,9 +4,9 @@ from ..field import Field
from ..inputfield import InputField from ..inputfield import InputField
from ..inputobjecttype import InputObjectType from ..inputobjecttype import InputObjectType
from ..objecttype import ObjectType from ..objecttype import ObjectType
from ..unmountedtype import UnmountedType from ..scalars import Boolean, String
from ..scalars import String, Boolean
from ..schema import Schema from ..schema import Schema
from ..unmountedtype import UnmountedType
class MyType(object): class MyType(object):

View File

@ -3,10 +3,10 @@ import pytest
from ..field import Field from ..field import Field
from ..interface import Interface from ..interface import Interface
from ..objecttype import ObjectType from ..objecttype import ObjectType
from ..unmountedtype import UnmountedType
from ..structures import NonNull
from ..scalars import String from ..scalars import String
from ..schema import Schema from ..schema import Schema
from ..structures import NonNull
from ..unmountedtype import UnmountedType
class MyType(Interface): class MyType(Interface):

View File

@ -1,19 +1,19 @@
import json import json
from functools import partial from functools import partial
from graphql import GraphQLError, Source, execute, parse, ResolveInfo from graphql import GraphQLError, ResolveInfo, Source, execute, parse
from ..context import Context
from ..dynamic import Dynamic from ..dynamic import Dynamic
from ..field import Field from ..field import Field
from ..inputfield import InputField from ..inputfield import InputField
from ..inputobjecttype import InputObjectType from ..inputobjecttype import InputObjectType
from ..interface import Interface from ..interface import Interface
from ..objecttype import ObjectType from ..objecttype import ObjectType
from ..scalars import Int, String, Boolean from ..scalars import Boolean, Int, String
from ..schema import Schema from ..schema import Schema
from ..structures import List, NonNull from ..structures import List, NonNull
from ..union import Union from ..union import Union
from ..context import Context
def test_query(): def test_query():

View File

@ -1,11 +1,9 @@
import pytest import pytest
from graphql.type import (GraphQLArgument, GraphQLEnumType, GraphQLEnumValue, from graphql.type import (GraphQLArgument, GraphQLEnumType, GraphQLEnumValue,
GraphQLField, GraphQLInputObjectField, GraphQLField, GraphQLInputObjectField,
GraphQLInputObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLInterfaceType,
GraphQLObjectType, GraphQLString) GraphQLObjectType, GraphQLString)
from ..structures import List, NonNull
from ..dynamic import Dynamic from ..dynamic import Dynamic
from ..enum import Enum from ..enum import Enum
from ..field import Field from ..field import Field
@ -13,7 +11,8 @@ from ..inputfield import InputField
from ..inputobjecttype import InputObjectType from ..inputobjecttype import InputObjectType
from ..interface import Interface from ..interface import Interface
from ..objecttype import ObjectType from ..objecttype import ObjectType
from ..scalars import String, Int from ..scalars import Int, String
from ..structures import List, NonNull
from ..typemap import TypeMap, resolve_type from ..typemap import TypeMap, resolve_type

View File

@ -1,6 +1,6 @@
from ..uuid import UUID
from ..objecttype import ObjectType from ..objecttype import ObjectType
from ..schema import Schema from ..schema import Schema
from ..uuid import UUID
class Query(ObjectType): class Query(ObjectType):

View File

@ -1,7 +1,6 @@
from .base import BaseOptions, BaseType from .base import BaseOptions, BaseType
from .unmountedtype import UnmountedType from .unmountedtype import UnmountedType
# For static type checking with Mypy # For static type checking with Mypy
MYPY = False MYPY = False
if MYPY: if MYPY:

View File

@ -1,6 +1,6 @@
import six import six
from ..pyutils.compat import signature, func_name
from ..pyutils.compat import func_name, signature
from .deprecated import warn_deprecation from .deprecated import warn_deprecation

View File

@ -1,4 +1,5 @@
from functools import wraps from functools import wraps
from .deprecated import deprecated from .deprecated import deprecated

View File

@ -1,6 +1,7 @@
import six
from inspect import isclass from inspect import isclass
import six
from ..pyutils.init_subclass import InitSubclassMeta from ..pyutils.init_subclass import InitSubclassMeta
from .props import props from .props import props

View File

@ -1,4 +1,5 @@
import pytest import pytest
from ..annotate import annotate from ..annotate import annotate

View File

@ -1,6 +1,8 @@
import pytest import pytest
from .. import deprecated from .. import deprecated
from ..deprecated import deprecated as deprecated_decorator, warn_deprecation from ..deprecated import deprecated as deprecated_decorator
from ..deprecated import warn_deprecation
def test_warn_deprecation(mocker): def test_warn_deprecation(mocker):

View File

@ -1,5 +1,5 @@
from ..resolve_only_args import resolve_only_args
from .. import deprecated from .. import deprecated
from ..resolve_only_args import resolve_only_args
def test_resolve_only_args(mocker): def test_resolve_only_args(mocker):

View File

@ -1,8 +1,9 @@
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
import sys
import ast import ast
import re import re
import sys
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
_version_re = re.compile(r'VERSION\s+=\s+(.*)') _version_re = re.compile(r'VERSION\s+=\s+(.*)')

13
tox.ini
View File

@ -3,18 +3,7 @@ envlist = flake8,py27,py33,py34,py35,py36,pre-commit,pypy
skipsdist = true skipsdist = true
[testenv] [testenv]
deps= deps = .[test]
pytest>=2.7.2
graphql-core>=1.1
promise>=2.0
graphql-relay>=0.4.5
six
blinker
singledispatch
mock
pytz
iso8601
pytest-benchmark
setenv = setenv =
PYTHONPATH = .:{envdir} PYTHONPATH = .:{envdir}
commands= commands=