diff --git a/.ruff.toml b/.ruff.toml index aa08a7b..b58fa1e 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -2,6 +2,7 @@ select = [ "E", # pycodestyle "W", # pycodestyle "F", # pyflake + "UP", # pyupgrade ] ignore = [ diff --git a/graphene_django/converter.py b/graphene_django/converter.py index f27119a..eda3a02 100644 --- a/graphene_django/converter.py +++ b/graphene_django/converter.py @@ -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__})" ) diff --git a/graphene_django/filter/tests/test_in_filter.py b/graphene_django/filter/tests/test_in_filter.py index a69d6f5..a64f736 100644 --- a/graphene_django/filter/tests/test_in_filter.py +++ b/graphene_django/filter/tests/test_in_filter.py @@ -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"] == [ diff --git a/graphene_django/forms/converter.py b/graphene_django/forms/converter.py index 47eb51d..449ab2e 100644 --- a/graphene_django/forms/converter.py +++ b/graphene_django/forms/converter.py @@ -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__) ) diff --git a/graphene_django/registry.py b/graphene_django/registry.py index 4708637..900feeb 100644 --- a/graphene_django/registry.py +++ b/graphene_django/registry.py @@ -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) diff --git a/graphene_django/rest_framework/serializer_converter.py b/graphene_django/rest_framework/serializer_converter.py index 1d850f0..a680de4 100644 --- a/graphene_django/rest_framework/serializer_converter.py +++ b/graphene_django/rest_framework/serializer_converter.py @@ -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__) ) diff --git a/graphene_django/types.py b/graphene_django/types.py index 5597e27..ba8e36d 100644 --- a/graphene_django/types.py +++ b/graphene_django/types.py @@ -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