Format with black

This commit is contained in:
Kumar Aditya 2021-02-03 14:54:58 +05:30
parent e7b0a6a2f9
commit 95698d485a
No known key found for this signature in database
GPG Key ID: B26DEFB517433892
35 changed files with 79 additions and 77 deletions

View File

@ -64,18 +64,18 @@ source_suffix = ".rst"
master_doc = "index"
# General information about the project.
project = u"Graphene"
copyright = u"Graphene 2016"
author = u"Syrus Akbary"
project = "Graphene"
copyright = "Graphene 2016"
author = "Syrus Akbary"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u"1.0"
version = "1.0"
# The full version, including alpha/beta/rc tags.
release = u"1.0"
release = "1.0"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -278,7 +278,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "Graphene.tex", u"Graphene Documentation", u"Syrus Akbary", "manual")
(master_doc, "Graphene.tex", "Graphene Documentation", "Syrus Akbary", "manual")
]
# The name of an image file (relative to this directory) to place at the top of
@ -318,7 +318,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "graphene", u"Graphene Documentation", [author], 1)]
man_pages = [(master_doc, "graphene", "Graphene Documentation", [author], 1)]
# If true, show URL addresses after external links.
#
@ -334,7 +334,7 @@ texinfo_documents = [
(
master_doc,
"Graphene",
u"Graphene Documentation",
"Graphene Documentation",
author,
"Graphene",
"One line description of project.",

View File

@ -3,7 +3,7 @@ droid_data = {}
def setup():
from .schema import Human, Droid
from .schema import Droid, Human
global human_data, droid_data
luke = Human(

View File

@ -4,7 +4,7 @@ data = {}
def setup():
global data
from .schema import Ship, Faction
from .schema import Faction, Ship
xwing = Ship(id="1", name="X-Wing")

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

@ -1,6 +1,6 @@
from .node import Node, is_node, GlobalID
from .mutation import ClientIDMutation
from .connection import Connection, ConnectionField, PageInfo
from .mutation import ClientIDMutation
from .node import GlobalID, Node, is_node
__all__ = [
"Node",

View File

@ -92,12 +92,10 @@ class Node(AbstractNode):
_type, _id = cls.from_global_id(global_id)
except Exception as e:
raise Exception(
(
f'Unable to parse global ID "{global_id}". '
'Make sure it is a base64 encoded string in the format: "TypeName:id". '
f"Exception message: {str(e)}"
)
)
graphene_type = info.schema.get_type(_type)
if graphene_type is None:

View File

@ -1,10 +1,9 @@
from graphql_relay.utils import base64
from pytest import mark
from graphql_relay.utils import base64
from graphene.types import ObjectType, Schema, String
from graphene.relay.connection import Connection, ConnectionField, PageInfo
from graphene.relay.node import Node
from graphene.types import ObjectType, Schema, String
letter_chars = ["A", "B", "C", "D", "E"]

View File

@ -1,6 +1,5 @@
from pytest import mark
from graphql_relay.utils import base64
from pytest import mark
from ...types import ObjectType, Schema, String
from ..connection import Connection, ConnectionField, PageInfo
@ -164,14 +163,16 @@ async def test_respects_first_and_after_and_before_too_few():
@mark.asyncio
async def test_respects_first_and_after_and_before_too_many():
await check(
f'first: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD",
f'first: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"',
"BCD",
)
@mark.asyncio
async def test_respects_first_and_after_and_before_exactly_right():
await check(
f'first: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD",
f'first: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"',
"BCD",
)
@ -187,14 +188,16 @@ async def test_respects_last_and_after_and_before_too_few():
@mark.asyncio
async def test_respects_last_and_after_and_before_too_many():
await check(
f'last: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD",
f'last: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"',
"BCD",
)
@mark.asyncio
async def test_respects_last_and_after_and_before_exactly_right():
await check(
f'last: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD",
f'last: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"',
"BCD",
)

View File

@ -1,8 +1,8 @@
from pytest import mark
from graphene.relay.mutation import ClientIDMutation
from graphene.types import ID, Field, ObjectType, Schema
from graphene.types.scalars import String
from graphene.relay.mutation import ClientIDMutation
class SharedFields(object):

View File

@ -1,4 +1,5 @@
import re
from graphql_relay import to_global_id
from graphene.tests.utils import dedent

View File

@ -1,6 +1,6 @@
from promise import Promise, is_thenable
from graphql.error import format_error as format_graphql_error
from graphql.error import GraphQLError
from graphql.error import format_error as format_graphql_error
from promise import Promise, is_thenable
from graphene.types.schema import Schema

View File

@ -71,9 +71,9 @@ class Argument(MountedType):
def to_arguments(args, extra_args=None):
from .unmountedtype import UnmountedType
from .field import Field
from .inputfield import InputField
from .unmountedtype import UnmountedType
if extra_args:
extra_args = sorted(extra_args.items(), key=lambda f: f[1])

View File

@ -1,5 +1,5 @@
from binascii import Error as _Error
from base64 import b64decode, b64encode
from binascii import Error as _Error
from graphql.error import GraphQLError
from graphql.language import StringValueNode, print_ast

View File

@ -2,7 +2,7 @@ from __future__ import absolute_import
from decimal import Decimal as _Decimal
from graphql.language.ast import StringValueNode, IntValueNode
from graphql.language.ast import IntValueNode, StringValueNode
from .scalars import Scalar

View File

@ -2,13 +2,13 @@ import inspect
from collections.abc import Mapping
from functools import partial
from ..utils.deprecated import warn_deprecation
from .argument import Argument, to_arguments
from .mountedtype import MountedType
from .resolver import default_resolver
from .structures import NonNull
from .unmountedtype import UnmountedType
from .utils import get_type
from ..utils.deprecated import warn_deprecation
base_type = type

View File

@ -55,7 +55,7 @@ class InputField(MountedType):
description=None,
required=False,
_creation_counter=None,
**extra_args
**extra_args,
):
super(InputField, self).__init__(_creation_counter=_creation_counter)
self.name = name

View File

@ -6,7 +6,7 @@ from .utils import yank_fields_from_attrs
# For static type checking with Mypy
MYPY = False
if MYPY:
from typing import Dict, Callable # NOQA
from typing import Callable, Dict # NOQA
class InputObjectTypeOptions(BaseOptions):

View File

@ -2,15 +2,16 @@ 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 .interface import Interface
from .objecttype import ObjectType, ObjectTypeOptions
from .utils import yank_fields_from_attrs
from .interface import Interface
# For static type checking with Mypy
MYPY = False
if MYPY:
from typing import Callable, Dict, Iterable, Type # NOQA
from .argument import Argument # NOQA
from typing import Dict, Type, Callable, Iterable # NOQA
class MutationOptions(ObjectTypeOptions):
@ -99,13 +100,11 @@ class Mutation(ObjectType):
input_class = getattr(cls, "Input", None)
if input_class:
warn_deprecation(
(
f"Please use {cls.__name__}.Arguments instead of {cls.__name__}.Input."
" Input is now only used in ClientMutationID.\n"
"Read more:"
" https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input"
)
)
if input_class:
arguments = props(input_class)

View File

@ -143,7 +143,7 @@ class String(Scalar):
@staticmethod
def coerce_string(value):
if isinstance(value, bool):
return u"true" if value else u"false"
return "true" if value else "false"
return str(value)
serialize = coerce_string

View File

@ -2,20 +2,11 @@ import inspect
from functools import partial
from graphql import (
default_type_resolver,
get_introspection_query,
graphql,
graphql_sync,
introspection_types,
parse,
print_schema,
subscribe,
validate,
ExecutionResult,
GraphQLArgument,
GraphQLBoolean,
GraphQLError,
GraphQLEnumValue,
GraphQLError,
GraphQLField,
GraphQLFloat,
GraphQLID,
@ -27,12 +18,21 @@ from graphql import (
GraphQLSchema,
GraphQLString,
Undefined,
default_type_resolver,
get_introspection_query,
graphql,
graphql_sync,
introspection_types,
parse,
print_schema,
subscribe,
validate,
)
from graphql.execution import ExecutionContext
from graphql.execution.values import get_argument_values
from ..utils.str_converters import to_camel_case
from ..utils.get_unbound_function import get_unbound_function
from ..utils.str_converters import to_camel_case
from .definitions import (
GrapheneEnumType,
GrapheneGraphQLType,

View File

@ -2,10 +2,10 @@ import base64
from graphql import GraphQLError
from ..base64 import Base64
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..base64 import Base64
class Query(ObjectType):
@ -72,7 +72,8 @@ def test_base64_query_invalid():
for input_ in bad_inputs:
result = schema.execute(
"""{ base64(input: $input) }""", variables={"input": input_},
"""{ base64(input: $input) }""",
variables={"input": input_},
)
assert isinstance(result.errors, list)
assert len(result.errors) == 1

View File

@ -2,7 +2,6 @@ import datetime
import pytz
from graphql import GraphQLError
from pytest import fixture
from ..datetime import Date, DateTime, Time

View File

@ -2,12 +2,12 @@ from pytest import raises
from ..argument import Argument
from ..dynamic import Dynamic
from ..interface import Interface
from ..mutation import Mutation
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..interface import Interface
class MyType(Interface):

View File

@ -1,13 +1,9 @@
import json
from functools import partial
from graphql import (
GraphQLError,
GraphQLResolveInfo as ResolveInfo,
Source,
execute,
parse,
)
from graphql import GraphQLError
from graphql import GraphQLResolveInfo as ResolveInfo
from graphql import Source, execute, parse
from ..context import Context
from ..dynamic import Dynamic

View File

@ -1,7 +1,7 @@
from ..resolver import (
attr_resolver,
dict_resolver,
dict_or_attr_resolver,
dict_resolver,
get_default_resolver,
set_default_resolver,
)

View File

@ -1,6 +1,7 @@
from ..scalars import Scalar, Int, BigInt
from graphql.language.ast import IntValueNode
from ..scalars import BigInt, Int, Scalar
def test_scalar():
class JSONScalar(Scalar):

View File

@ -38,7 +38,7 @@ def test_serializes_output_string():
assert String.serialize(-1.1) == "-1.1"
assert String.serialize(True) == "true"
assert String.serialize(False) == "false"
assert String.serialize(u"\U0001F601") == u"\U0001F601"
assert String.serialize("\U0001F601") == "\U0001F601"
def test_serializes_output_boolean():

View File

@ -1,6 +1,6 @@
from graphql.type import GraphQLObjectType, GraphQLSchema
from graphql import GraphQLError
from pytest import mark, raises, fixture
from graphql.type import GraphQLObjectType, GraphQLSchema
from pytest import fixture, mark, raises
from graphene.tests.utils import dedent

View File

@ -1,6 +1,6 @@
from pytest import mark
from graphene import ObjectType, Int, String, Schema, Field
from graphene import Field, Int, ObjectType, Schema, String
class Query(ObjectType):

View File

@ -18,8 +18,8 @@ from ..inputobjecttype import InputObjectType
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import Int, String
from ..structures import List, NonNull
from ..schema import Schema
from ..structures import List, NonNull
def create_type_map(types, auto_camelcase=True):

View File

@ -4,9 +4,10 @@ from .unmountedtype import UnmountedType
# For static type checking with Mypy
MYPY = False
if MYPY:
from .objecttype import ObjectType # NOQA
from typing import Iterable, Type # NOQA
from .objecttype import ObjectType # NOQA
class UnionOptions(BaseOptions):
types = () # type: Iterable[Type[ObjectType]]

View File

@ -1,4 +1,5 @@
from __future__ import absolute_import
from uuid import UUID as _UUID
from graphql.language.ast import StringValueNode

View File

@ -36,4 +36,4 @@ class OrderedType:
return NotImplemented
def __hash__(self):
return hash((self.creation_counter))
return hash(self.creation_counter)

View File

@ -1,4 +1,5 @@
import datetime
import graphene
from graphene import relay
from graphene.types.resolver import dict_resolver

View File

@ -1,7 +1,7 @@
[flake8]
exclude = setup.py,docs/*,*/examples/*,tests
max-line-length = 120
ignore = E741, W503
[coverage:run]
omit = */tests/*,graphene/types/scalars.py
@ -9,6 +9,9 @@ omit = */tests/*,graphene/types/scalars.py
profile = black
known_first_party=graphene
[black]
target-version = ['py37']
[mypy]
ignore_missing_imports = True