mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-13 05:34:20 +03:00
Add pyupgrade
This commit is contained in:
parent
add11cb9a6
commit
4da0841ec2
|
@ -2,6 +2,7 @@ select = [
|
|||
"E", # pycodestyle
|
||||
"W", # pycodestyle
|
||||
"F", # pyflake
|
||||
"UP", # pyupgrade
|
||||
]
|
||||
|
||||
ignore = [
|
||||
|
|
|
@ -161,9 +161,7 @@ def get_django_field_description(field):
|
|||
@singledispatch
|
||||
def convert_django_field(field, registry=None):
|
||||
raise Exception(
|
||||
"Don't know how to convert the Django field {} ({})".format(
|
||||
field, field.__class__
|
||||
)
|
||||
f"Don't know how to convert the Django field {field} ({field.__class__})"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -348,9 +348,9 @@ def test_fk_id_in_filter(query):
|
|||
|
||||
schema = Schema(query=query)
|
||||
|
||||
query = """
|
||||
query = f"""
|
||||
query {{
|
||||
articles (reporter_In: [{}, {}]) {{
|
||||
articles (reporter_In: [{john_doe.id}, {jean_bon.id}]) {{
|
||||
edges {{
|
||||
node {{
|
||||
headline
|
||||
|
@ -361,10 +361,7 @@ def test_fk_id_in_filter(query):
|
|||
}}
|
||||
}}
|
||||
}}
|
||||
""".format(
|
||||
john_doe.id,
|
||||
jean_bon.id,
|
||||
)
|
||||
"""
|
||||
result = schema.execute(query)
|
||||
assert not result.errors
|
||||
assert result.data["articles"]["edges"] == [
|
||||
|
|
|
@ -27,8 +27,8 @@ def get_form_field_description(field):
|
|||
@singledispatch
|
||||
def convert_form_field(field):
|
||||
raise ImproperlyConfigured(
|
||||
"Don't know how to convert the Django form field %s (%s) "
|
||||
"to Graphene type" % (field, field.__class__)
|
||||
"Don't know how to convert the Django form field {} ({}) "
|
||||
"to Graphene type".format(field, field.__class__)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -8,9 +8,7 @@ class Registry:
|
|||
|
||||
assert issubclass(
|
||||
cls, DjangoObjectType
|
||||
), 'Only DjangoObjectTypes can be registered, received "{}"'.format(
|
||||
cls.__name__
|
||||
)
|
||||
), f'Only DjangoObjectTypes can be registered, received "{cls.__name__}"'
|
||||
assert cls._meta.registry == self, "Registry for a Model have to match."
|
||||
# assert self.get_type_for_model(cls._meta.model) == cls, (
|
||||
# 'Multiple DjangoObjectTypes registered for "{}"'.format(cls._meta.model)
|
||||
|
|
|
@ -13,8 +13,8 @@ from .types import DictType
|
|||
@singledispatch
|
||||
def get_graphene_type_from_serializer_field(field):
|
||||
raise ImproperlyConfigured(
|
||||
"Don't know how to convert the serializer field %s (%s) "
|
||||
"to Graphene type" % (field, field.__class__)
|
||||
"Don't know how to convert the serializer field {} ({}) "
|
||||
"to Graphene type".format(field, field.__class__)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class DjangoObjectType(ObjectType):
|
|||
interfaces=(),
|
||||
convert_choices_to_enum=True,
|
||||
_meta=None,
|
||||
**options
|
||||
**options,
|
||||
):
|
||||
assert is_valid_django_model(model), (
|
||||
'You need to pass a valid Django Model in {}.Meta, received "{}".'
|
||||
|
@ -240,9 +240,9 @@ class DjangoObjectType(ObjectType):
|
|||
)
|
||||
|
||||
if connection is not None:
|
||||
assert issubclass(connection, Connection), (
|
||||
"The connection must be a Connection. Received {}"
|
||||
).format(connection.__name__)
|
||||
assert issubclass(
|
||||
connection, Connection
|
||||
), f"The connection must be a Connection. Received {connection.__name__}"
|
||||
|
||||
if not _meta:
|
||||
_meta = DjangoObjectTypeOptions(cls)
|
||||
|
@ -273,7 +273,7 @@ class DjangoObjectType(ObjectType):
|
|||
if isinstance(root, cls):
|
||||
return True
|
||||
if not is_valid_django_model(root.__class__):
|
||||
raise Exception(('Received incompatible instance "{}".').format(root))
|
||||
raise Exception(f'Received incompatible instance "{root}".')
|
||||
|
||||
if cls._meta.model._meta.proxy:
|
||||
model = root._meta.model
|
||||
|
|
Loading…
Reference in New Issue
Block a user