mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-16 19:40:39 +03:00
Add flake8 pre-commit hook and manually edit files to pass flake8 validation (#746)
Add flake8 pre-commit hook and manually edit files to pass flake8 validation
This commit is contained in:
parent
8bf937d1ff
commit
1b3e7f3b96
|
@ -1,6 +1,6 @@
|
|||
repos:
|
||||
- repo: git://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v1.2.3
|
||||
rev: v1.3.0
|
||||
hooks:
|
||||
- id: autopep8-wrapper
|
||||
args:
|
||||
|
@ -16,6 +16,7 @@ repos:
|
|||
- id: pretty-format-json
|
||||
args:
|
||||
- --autofix
|
||||
- id: flake8
|
||||
- repo: https://github.com/asottile/seed-isort-config
|
||||
rev: v1.0.0
|
||||
hooks:
|
||||
|
|
|
@ -56,8 +56,7 @@ schema = Schema(Query)
|
|||
|
||||
letters = OrderedDict()
|
||||
for i, letter in enumerate(letter_chars):
|
||||
l = Letter(id=i, letter=letter)
|
||||
letters[letter] = l
|
||||
letters[letter] = Letter(id=i, letter=letter)
|
||||
|
||||
|
||||
def edges(selected_letters):
|
||||
|
@ -74,8 +73,8 @@ def edges(selected_letters):
|
|||
|
||||
|
||||
def cursor_for(ltr):
|
||||
l = letters[ltr]
|
||||
return base64('arrayconnection:%s' % l.id)
|
||||
letter = letters[ltr]
|
||||
return base64('arrayconnection:%s' % letter.id)
|
||||
|
||||
|
||||
def execute(args=''):
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# https://github.com/graphql-python/graphene/issues/313
|
||||
|
||||
import graphene
|
||||
from graphene import resolve_only_args
|
||||
|
||||
|
||||
class Query(graphene.ObjectType):
|
||||
|
|
|
@ -21,10 +21,13 @@ class MyUnion(graphene.Union):
|
|||
|
||||
|
||||
def test_issue():
|
||||
class Query(graphene.ObjectType):
|
||||
things = relay.ConnectionField(MyUnion)
|
||||
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
class Query(graphene.ObjectType):
|
||||
things = relay.ConnectionField(MyUnion)
|
||||
graphene.Schema(query=Query)
|
||||
|
||||
schema = graphene.Schema(query=Query)
|
||||
|
||||
assert str(exc_info.value) == 'IterableConnectionField type have to be a subclass of Connection. Received "MyUnion".'
|
||||
assert str(exc_info.value) == (
|
||||
'IterableConnectionField type have to be a subclass of Connection. '
|
||||
'Received "MyUnion".'
|
||||
)
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
# Adapted for Graphene 2.0
|
||||
|
||||
from graphene.types.enum import Enum, EnumOptions
|
||||
from graphene.types.inputobjecttype import (InputObjectType,
|
||||
InputObjectTypeOptions)
|
||||
from graphene.types.inputobjecttype import InputObjectType
|
||||
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import pytest
|
||||
|
||||
from .. import abstracttype
|
||||
from ..abstracttype import AbstractType
|
||||
from ..field import Field
|
||||
|
|
|
@ -51,7 +51,10 @@ def test_to_arguments_raises_if_field():
|
|||
with pytest.raises(ValueError) as exc_info:
|
||||
to_arguments(args)
|
||||
|
||||
assert str(exc_info.value) == 'Expected arg_string to be Argument, but received Field. Try using Argument(String).'
|
||||
assert str(exc_info.value) == (
|
||||
'Expected arg_string to be Argument, but received Field. Try using '
|
||||
'Argument(String).'
|
||||
)
|
||||
|
||||
|
||||
def test_to_arguments_raises_if_inputfield():
|
||||
|
@ -62,7 +65,10 @@ def test_to_arguments_raises_if_inputfield():
|
|||
with pytest.raises(ValueError) as exc_info:
|
||||
to_arguments(args)
|
||||
|
||||
assert str(exc_info.value) == 'Expected arg_string to be Argument, but received InputField. Try using Argument(String).'
|
||||
assert str(exc_info.value) == (
|
||||
'Expected arg_string to be Argument, but received InputField. Try '
|
||||
'using Argument(String).'
|
||||
)
|
||||
|
||||
|
||||
def test_argument_with_lazy_type():
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import pytest
|
||||
|
||||
from ..base import BaseOptions, BaseType
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ def test_bad_datetime_query():
|
|||
|
||||
assert len(result.errors) == 1
|
||||
assert isinstance(result.errors[0], GraphQLError)
|
||||
assert result.data == None
|
||||
assert result.data is None
|
||||
|
||||
|
||||
def test_bad_date_query():
|
||||
|
@ -72,7 +72,7 @@ def test_bad_date_query():
|
|||
|
||||
assert len(result.errors) == 1
|
||||
assert isinstance(result.errors[0], GraphQLError)
|
||||
assert result.data == None
|
||||
assert result.data is None
|
||||
|
||||
|
||||
def test_bad_time_query():
|
||||
|
@ -82,7 +82,7 @@ def test_bad_time_query():
|
|||
|
||||
assert len(result.errors) == 1
|
||||
assert isinstance(result.errors[0], GraphQLError)
|
||||
assert result.data == None
|
||||
assert result.data is None
|
||||
|
||||
|
||||
def test_datetime_query_variable():
|
||||
|
|
|
@ -288,7 +288,14 @@ def test_stringifies_simple_types():
|
|||
# ]
|
||||
# for x in bad_union_types:
|
||||
# with raises(Exception) as excinfo:
|
||||
# GraphQLSchema(GraphQLObjectType('Root', fields={'union': GraphQLField(GraphQLUnionType('BadUnion', [x]))}))
|
||||
# GraphQLSchema(
|
||||
# GraphQLObjectType(
|
||||
# 'Root',
|
||||
# fields={
|
||||
# 'union': GraphQLField(GraphQLUnionType('BadUnion', [x]))
|
||||
# }
|
||||
# )
|
||||
# )
|
||||
|
||||
# assert 'BadUnion may only contain Object types, it cannot contain: ' + str(x) + '.' \
|
||||
# == str(excinfo.value)
|
||||
|
|
|
@ -96,8 +96,8 @@ def test_enum_from_builtin_enum_accepts_lambda_description():
|
|||
assert GraphQLPyEpisode[2].name == 'JEDI' and GraphQLPyEpisode[2].description == 'Other'
|
||||
|
||||
assert GraphQLPyEpisode[0].name == 'NEWHOPE' and GraphQLPyEpisode[0].deprecation_reason == 'meh'
|
||||
assert GraphQLPyEpisode[1].name == 'EMPIRE' and GraphQLPyEpisode[1].deprecation_reason == None
|
||||
assert GraphQLPyEpisode[2].name == 'JEDI' and GraphQLPyEpisode[2].deprecation_reason == None
|
||||
assert GraphQLPyEpisode[1].name == 'EMPIRE' and GraphQLPyEpisode[1].deprecation_reason is None
|
||||
assert GraphQLPyEpisode[2].name == 'JEDI' and GraphQLPyEpisode[2].deprecation_reason is None
|
||||
|
||||
|
||||
def test_enum_from_python3_enum_uses_enum_doc():
|
||||
|
|
|
@ -442,8 +442,6 @@ def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark
|
|||
|
||||
|
||||
def test_query_annotated_resolvers():
|
||||
import json
|
||||
|
||||
context = Context(key="context")
|
||||
|
||||
class Query(ObjectType):
|
||||
|
|
|
@ -67,8 +67,7 @@ def test_objecttype():
|
|||
foo_field = fields['foo']
|
||||
assert isinstance(foo_field, GraphQLField)
|
||||
assert foo_field.description == 'Field description'
|
||||
f = MyObjectType.resolve_foo
|
||||
# assert foo_field.resolver == getattr(f, '__func__', f)
|
||||
|
||||
assert foo_field.args == {
|
||||
'bar': GraphQLArgument(GraphQLString, description='Argument description', default_value='x', out_name='bar')
|
||||
}
|
||||
|
|
|
@ -34,6 +34,6 @@ def test_annotate_with_params():
|
|||
|
||||
def test_annotate_with_wront_params():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
annotated_func = annotate(p=int, _trigger_warning=False)(func)
|
||||
annotate(p=int, _trigger_warning=False)(func)
|
||||
|
||||
assert str(exc_info.value) == 'The key p is not a function parameter in the function "func".'
|
||||
|
|
|
@ -63,5 +63,5 @@ def test_deprecated_class_text(mocker):
|
|||
def test_deprecated_other_object(mocker):
|
||||
mocker.patch.object(deprecated, 'warn_deprecation')
|
||||
|
||||
with pytest.raises(TypeError) as exc_info:
|
||||
with pytest.raises(TypeError):
|
||||
deprecated_decorator({})
|
||||
|
|
|
@ -8,8 +8,6 @@ def test_resolve_only_args(mocker):
|
|||
def resolver(root, **args):
|
||||
return root, args
|
||||
|
||||
my_data = {'one': 1, 'two': 2}
|
||||
|
||||
wrapped_resolver = resolve_only_args(resolver)
|
||||
assert deprecated.warn_deprecation.called
|
||||
result = wrapped_resolver(1, 2, a=3)
|
||||
|
|
Loading…
Reference in New Issue
Block a user