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}]
indent_style = space
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
sha: v0.8.0
rev: v1.2.3
hooks:
- id: autopep8-wrapper
args:
@ -15,3 +16,11 @@
- id: pretty-format-json
args:
- --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

@ -207,7 +207,7 @@ Before:
```python
class SomeMutation(Mutation):
...
@classmethod
def mutate(cls, instance, args, context, info):
...
@ -218,7 +218,7 @@ With 2.0:
```python
class SomeMutation(Mutation):
...
def mutate(self, info, **args):
...
```
@ -231,7 +231,7 @@ class SomeMutation(Mutation):
first_name = String(required=True)
last_name = String(required=True)
...
def mutate(self, info, first_name, last_name):
...
```
@ -250,7 +250,7 @@ If you are using Middelwares, you need to some adjustments:
Before:
```python
class MyGrapheneMiddleware(object):
class MyGrapheneMiddleware(object):
def resolve(self, next_mw, root, args, context, info):
## Middleware code
@ -261,7 +261,7 @@ class MyGrapheneMiddleware(object):
With 2.0:
```python
class MyGrapheneMiddleware(object):
class MyGrapheneMiddleware(object):
def resolve(self, next_mw, root, info, **args):
context = info.context

View File

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

View File

@ -88,7 +88,7 @@ Naively, if ``me``, ``bestFriend`` and ``friends`` each need to request the back
there could be at most 13 database requests!
When using DataLoader, we could define the User type using our previous example with
When using DataLoader, we could define the User type using our previous example with
leaner code and at most 4 database requests, and possibly fewer if there are cache hits.

View File

@ -41,7 +41,7 @@ Mutations can also accept files, that's how it will work with different integrat
class Input:
pass
# nothing needed for uploading file
# your return fields
success = graphene.String()

View File

@ -101,7 +101,7 @@ Here is a simple example on how our tests will look if we use ``pytest``:
If we are using ``unittest``:
.. code:: python
from snapshottest import TestCase
class APITestCase(TestCase):

View File

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

View File

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

View File

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

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals
from snapshottest import Snapshot
snapshots = Snapshot()
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
VERSION = (2, 1, 0, 'final', 0)
VERSION = (2, 1, 1, 'final', 0)
__version__ = get_version(VERSION)

View File

@ -1,4 +1,5 @@
from __future__ import absolute_import
import six
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+.
"""
from __future__ import absolute_import, division, print_function
import itertools
import functools
import itertools
import re
import types
from collections import OrderedDict
__version__ = "0.4"

View File

@ -1,6 +1,7 @@
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 ..node import Node

View File

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

View File

@ -1,9 +1,10 @@
# https://github.com/graphql-python/graphene/issues/425
# 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.inputobjecttype import (InputObjectType,
InputObjectTypeOptions)
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
# ObjectType

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
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,
GraphQLSkipDirective)
from graphql.type.introspection import IntrospectionSchema

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
from functools import partial
from ..dynamic import Dynamic
from ..scalars import String
from ..structures import List, NonNull
@ -25,3 +27,11 @@ def test_list_non_null():
dynamic = Dynamic(lambda: List(NonNull(String)))
assert dynamic.get_type().of_type.of_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
from ..schema import Schema, ObjectType
from ..argument import Argument
from ..enum import Enum, PyEnum
from ..field import Field
from ..inputfield import InputField
from ..schema import ObjectType, Schema
def test_enum_construction():

View File

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

View File

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

View File

@ -1,19 +1,19 @@
import json
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 ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import Int, String, Boolean
from ..scalars import Boolean, Int, String
from ..schema import Schema
from ..structures import List, NonNull
from ..union import Union
from ..context import Context
def test_query():

View File

@ -1,11 +1,9 @@
import pytest
from graphql.type import (GraphQLArgument, GraphQLEnumType, GraphQLEnumValue,
GraphQLField, GraphQLInputObjectField,
GraphQLInputObjectType, GraphQLInterfaceType,
GraphQLObjectType, GraphQLString)
from ..structures import List, NonNull
from ..dynamic import Dynamic
from ..enum import Enum
from ..field import Field
@ -13,7 +11,8 @@ from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..interface import Interface
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
import pytest
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):

View File

@ -1,5 +1,5 @@
from ..resolve_only_args import resolve_only_args
from .. import deprecated
from ..resolve_only_args import resolve_only_args
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 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+(.*)')

13
tox.ini
View File

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