mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-21 17:16:43 +03:00
Add isort precommit hook & run on all files (#743)
* Add isort and seed-isort-config pre-commit hook * Fix erroneous isort moving comment to the top of file
This commit is contained in:
parent
9f678fdfe8
commit
034b5385a5
|
@ -11,4 +11,3 @@ trim_trailing_whitespace = true
|
|||
[*.{py,rst,ini}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
|
|
2
.isort.cfg
Normal file
2
.isort.cfg
Normal file
|
@ -0,0 +1,2 @@
|
|||
[settings]
|
||||
known_third_party = aniso8601,graphql,graphql_relay,promise,pytest,pytz,pyutils,setuptools,six,snapshottest,sphinx_graphene_theme
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import unicode_literals
|
|||
|
||||
from snapshottest import Snapshot
|
||||
|
||||
|
||||
snapshots = Snapshot()
|
||||
|
||||
snapshots['test_hero_name_query 1'] = {
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import unicode_literals
|
|||
|
||||
from snapshottest import Snapshot
|
||||
|
||||
|
||||
snapshots = Snapshot()
|
||||
|
||||
snapshots['test_correct_fetch_first_ship_rebels 1'] = {
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import unicode_literals
|
|||
|
||||
from snapshottest import Snapshot
|
||||
|
||||
|
||||
snapshots = Snapshot()
|
||||
|
||||
snapshots['test_mutations 1'] = {
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import unicode_literals
|
|||
|
||||
from snapshottest import Snapshot
|
||||
|
||||
|
||||
snapshots = Snapshot()
|
||||
|
||||
snapshots['test_correctly_fetches_id_name_rebels 1'] = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
|
||||
try:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import pytest
|
||||
|
||||
from promise import Promise
|
||||
|
||||
from ...types import (ID, Argument, Field, InputField, InputObjectType,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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__):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import six
|
||||
|
||||
from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
|
||||
StringValue)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from ..base import BaseType, BaseOptions
|
||||
from ..base import BaseOptions, BaseType
|
||||
|
||||
|
||||
class CustomOptions(BaseOptions):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from functools import partial
|
||||
|
||||
from ..dynamic import Dynamic
|
||||
from ..scalars import String
|
||||
from ..structures import List, NonNull
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from ..uuid import UUID
|
||||
from ..objecttype import ObjectType
|
||||
from ..schema import Schema
|
||||
from ..uuid import UUID
|
||||
|
||||
|
||||
class Query(ObjectType):
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from .base import BaseOptions, BaseType
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
# For static type checking with Mypy
|
||||
MYPY = False
|
||||
if MYPY:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from functools import wraps
|
||||
|
||||
from .deprecated import deprecated
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import six
|
||||
from inspect import isclass
|
||||
|
||||
import six
|
||||
|
||||
from ..pyutils.init_subclass import InitSubclassMeta
|
||||
from .props import props
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
|
||||
from ..annotate import annotate
|
||||
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
7
setup.py
7
setup.py
|
@ -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+(.*)')
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user