From cff900e8e40bb2b085fa89f622a245b6cb1f95df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:25:24 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- apischema/aliases.py | 9 +++------ apischema/conversions/converters.py | 12 ++++------- apischema/dependencies.py | 12 +++++------ apischema/deserialization/__init__.py | 20 +++++++++---------- apischema/deserialization/methods.py | 6 +++--- apischema/graphql/relay/mutations.py | 8 +++++--- apischema/graphql/resolvers.py | 6 ++---- apischema/json_schema/refs.py | 6 +++--- apischema/json_schema/schema.py | 20 +++++++++++-------- apischema/json_schema/types.py | 3 +-- apischema/objects/fields.py | 6 +++--- apischema/objects/getters.py | 12 ++++------- apischema/ordering.py | 15 +++++--------- apischema/recursion.py | 8 +++++--- apischema/serialization/__init__.py | 6 ++---- apischema/serialization/serialized_methods.py | 6 ++---- apischema/settings.py | 12 +++++------ apischema/tagged_unions.py | 6 ++---- apischema/typing.py | 1 + apischema/validation/errors.py | 15 +++++--------- apischema/validation/validators.py | 6 ++---- examples/additional_types.py | 3 +-- examples/base_schema_parameter.py | 3 +-- examples/examples/sqlalchemy_support.py | 3 +-- examples/graphql_type_name.py | 3 +-- examples/id_type.py | 3 +-- examples/interface.py | 3 +-- examples/object_serialization.py | 3 +-- examples/operation.py | 6 ++---- examples/quickstart.py | 3 +-- examples/relay_client_mutation_id.py | 9 +++------ examples/relay_connection_subclass.py | 3 +-- examples/relay_mutation.py | 9 +++------ examples/relay_node.py | 8 ++++---- examples/resolver.py | 6 ++---- examples/scalar.py | 3 +-- examples/serialized_generic.py | 9 +++------ examples/sub_conversions.py | 12 ++++------- examples/union_type_name.py | 3 +-- tests/unit/test_utils.py | 6 ++---- 40 files changed, 118 insertions(+), 175 deletions(-) diff --git a/apischema/aliases.py b/apischema/aliases.py index 572a1c5d..9058c60f 100644 --- a/apischema/aliases.py +++ b/apischema/aliases.py @@ -12,18 +12,15 @@ @overload -def alias(alias_: str, *, override: bool = True) -> Metadata: - ... +def alias(alias_: str, *, override: bool = True) -> Metadata: ... @overload -def alias(override: bool) -> Metadata: - ... +def alias(override: bool) -> Metadata: ... @overload -def alias(aliaser: Aliaser) -> Callable[[Cls], Cls]: - ... +def alias(aliaser: Aliaser) -> Callable[[Cls], Cls]: ... def alias(arg=None, *, override: bool = True): # type: ignore diff --git a/apischema/conversions/converters.py b/apischema/conversions/converters.py index 5ce93b9e..f4a6883d 100644 --- a/apischema/conversions/converters.py +++ b/apischema/conversions/converters.py @@ -86,15 +86,13 @@ def __set_name__(self, owner, name): @overload -def deserializer(deserializer: Deserializer) -> Deserializer: - ... +def deserializer(deserializer: Deserializer) -> Deserializer: ... @overload def deserializer( *, lazy: Callable[[], Union[Converter, Conversion]], target: Type -) -> None: - ... +) -> None: ... def deserializer( @@ -130,15 +128,13 @@ def __set_name__(self, owner, name): @overload -def serializer(serializer: Serializer) -> Serializer: - ... +def serializer(serializer: Serializer) -> Serializer: ... @overload def serializer( *, lazy: Callable[[], Union[Converter, Conversion]], source: Type -) -> Callable[[Serializer], Serializer]: - ... +) -> Callable[[Serializer], Serializer]: ... def serializer( diff --git a/apischema/dependencies.py b/apischema/dependencies.py index 38a663ca..ad3b4942 100644 --- a/apischema/dependencies.py +++ b/apischema/dependencies.py @@ -17,9 +17,9 @@ from apischema.cache import CacheAwareDict from apischema.objects.fields import check_field_or_name, get_field_name -_dependent_requireds: MutableMapping[ - type, List[Tuple[Any, Collection[Any]]] -] = CacheAwareDict(defaultdict(list)) +_dependent_requireds: MutableMapping[type, List[Tuple[Any, Collection[Any]]]] = ( + CacheAwareDict(defaultdict(list)) +) DependentRequired = Mapping[str, AbstractSet[str]] @@ -47,13 +47,11 @@ def dependent_required( fields: Mapping[Any, Collection[Any]], *groups: Collection[Any], owner: Optional[type] = None, -): - ... +): ... @overload -def dependent_required(*groups: Collection[Any], owner: Optional[type] = None): - ... +def dependent_required(*groups: Collection[Any], owner: Optional[type] = None): ... def dependent_required(*groups: Collection[Any], owner: Optional[type] = None): # type: ignore diff --git a/apischema/deserialization/__init__.py b/apischema/deserialization/__init__.py index bd04fc72..12dd5847 100644 --- a/apischema/deserialization/__init__.py +++ b/apischema/deserialization/__init__.py @@ -652,9 +652,11 @@ def _visit_conversion( def factory(constraints: Optional[Constraints], _) -> DeserializationMethod: conv_alternatives = tuple( ConversionAlternative( - conv.converter.func - if isinstance(conv.converter, ValueErrorCatcher) - else conv.converter, + ( + conv.converter.func + if isinstance(conv.converter, ValueErrorCatcher) + else conv.converter + ), (fact if dynamic else fact.merge(constraints)).method, isinstance(conv.converter, ValueErrorCatcher), ) @@ -743,8 +745,7 @@ def deserialization_method( pass_through: Optional[CollectionOrPredicate[type]] = None, schema: Optional[Schema] = None, validators: Collection[Callable] = (), -) -> Callable[[Any], T]: - ... +) -> Callable[[Any], T]: ... @overload @@ -761,8 +762,7 @@ def deserialization_method( pass_through: Optional[CollectionOrPredicate[type]] = None, schema: Optional[Schema] = None, validators: Collection[Callable] = (), -) -> Callable[[Any], Any]: - ... +) -> Callable[[Any], Any]: ... def deserialization_method( @@ -821,8 +821,7 @@ def deserialize( pass_through: Optional[CollectionOrPredicate[type]] = None, schema: Optional[Schema] = None, validators: Collection[Callable] = (), -) -> T: - ... +) -> T: ... @overload @@ -840,8 +839,7 @@ def deserialize( pass_through: Optional[CollectionOrPredicate[type]] = None, schema: Optional[Schema] = None, validators: Collection[Callable] = (), -) -> Any: - ... +) -> Any: ... def deserialize( diff --git a/apischema/deserialization/methods.py b/apischema/deserialization/methods.py index 5d63ac7f..9005aba7 100644 --- a/apischema/deserialization/methods.py +++ b/apischema/deserialization/methods.py @@ -648,9 +648,9 @@ def deserialize(self, data: Any) -> Any: if self.additional_field is not None: additional: dict = {key: data[key] for key in remain} try: - values[ - self.additional_field.name - ] = self.additional_field.method.deserialize(additional) + values[self.additional_field.name] = ( + self.additional_field.method.deserialize(additional) + ) except ValidationError as err: if not self.additional_field.fall_back_on_default: errors = extend_errors(errors, err.messages) diff --git a/apischema/graphql/relay/mutations.py b/apischema/graphql/relay/mutations.py index 80ed9d15..fec1eea8 100644 --- a/apischema/graphql/relay/mutations.py +++ b/apischema/graphql/relay/mutations.py @@ -79,9 +79,11 @@ def __init_subclass__(cls, **kwargs): fields.append( ( CLIENT_MUTATION_ID, - ClientMutationId - if cls._client_mutation_id - else Optional[ClientMutationId], + ( + ClientMutationId + if cls._client_mutation_id + else Optional[ClientMutationId] + ), # TODO why missing here? MISSING if cls._client_mutation_id else None, # type: ignore ) diff --git a/apischema/graphql/resolvers.py b/apischema/graphql/resolvers.py index 93782223..d4d2d8c9 100644 --- a/apischema/graphql/resolvers.py +++ b/apischema/graphql/resolvers.py @@ -159,8 +159,7 @@ def resolver_parameters( @overload -def resolver(__method_or_property: MethodOrProp) -> MethodOrProp: - ... +def resolver(__method_or_property: MethodOrProp) -> MethodOrProp: ... @overload @@ -174,8 +173,7 @@ def resolver( parameters_metadata: Optional[Mapping[str, Mapping]] = None, serialized: bool = False, owner: Optional[Type] = None, -) -> Callable[[MethodOrProp], MethodOrProp]: - ... +) -> Callable[[MethodOrProp], MethodOrProp]: ... def resolver( diff --git a/apischema/json_schema/refs.py b/apischema/json_schema/refs.py index 7fc97305..da9f8adc 100644 --- a/apischema/json_schema/refs.py +++ b/apischema/json_schema/refs.py @@ -54,9 +54,9 @@ class RefsExtractor(ConversionsVisitor, ObjectVisitor, WithConversionsResolver): def __init__(self, default_conversion: DefaultConversion, refs: Refs): super().__init__(default_conversion) self.refs = refs - self._rec_guard: Dict[ - Tuple[AnyType, Optional[AnyConversion]], int - ] = defaultdict(lambda: 0) + self._rec_guard: Dict[Tuple[AnyType, Optional[AnyConversion]], int] = ( + defaultdict(lambda: 0) + ) def _incr_ref(self, ref: Optional[str], tp: AnyType) -> bool: if ref is None: diff --git a/apischema/json_schema/schema.py b/apischema/json_schema/schema.py index f0c4fb65..4796c377 100644 --- a/apischema/json_schema/schema.py +++ b/apischema/json_schema/schema.py @@ -369,9 +369,11 @@ def _visited_union(self, results: Sequence[JsonSchema]) -> JsonSchema: return JsonSchema() elif all(alt.keys() == {"type"} for alt in results): types: Any = chain.from_iterable( - [res["type"]] - if isinstance(res["type"], (str, JsonType)) - else res["type"] + ( + [res["type"]] + if isinstance(res["type"], (str, JsonType)) + else res["type"] + ) for res in results ) return json_schema(type=list(types)) @@ -513,11 +515,13 @@ def properties( for field in fields if not field.is_aggregate for required in [ - field.required - if is_typed_dict(get_origin_or_type(tp)) - else not field.skippable( - settings.serialization.exclude_defaults, - settings.serialization.exclude_none, + ( + field.required + if is_typed_dict(get_origin_or_type(tp)) + else not field.skippable( + settings.serialization.exclude_defaults, + settings.serialization.exclude_none, + ) ) ] ] + [ diff --git a/apischema/json_schema/types.py b/apischema/json_schema/types.py index cf83e664..58956099 100644 --- a/apischema/json_schema/types.py +++ b/apischema/json_schema/types.py @@ -134,5 +134,4 @@ def json_schema( uniqueItems: bool = False, unevaluatedProperties: Union[bool, JsonSchema] = True, writeOnly: bool = False, -) -> JsonSchema: - ... +) -> JsonSchema: ... diff --git a/apischema/objects/fields.py b/apischema/objects/fields.py index 15a1dc33..2696594d 100644 --- a/apischema/objects/fields.py +++ b/apischema/objects/fields.py @@ -240,9 +240,9 @@ def get_field_name(field_or_name: Any, *, methods: bool = False) -> str: _bad_field(field_or_name, methods) -_class_fields: MutableMapping[ - type, Callable[[], Sequence[ObjectField]] -] = CacheAwareDict({}) +_class_fields: MutableMapping[type, Callable[[], Sequence[ObjectField]]] = ( + CacheAwareDict({}) +) def set_object_fields( diff --git a/apischema/objects/getters.py b/apischema/objects/getters.py index a5e71289..a5f618fd 100644 --- a/apischema/objects/getters.py +++ b/apischema/objects/getters.py @@ -73,13 +73,11 @@ def __getattribute__(self, name: str) -> ObjectField: @overload -def get_field(obj: Type[T]) -> T: - ... +def get_field(obj: Type[T]) -> T: ... @overload -def get_field(obj: T) -> T: - ... +def get_field(obj: T) -> T: ... # Overload because of Mypy issue @@ -104,13 +102,11 @@ def __getattribute__(self, name: str) -> str: @overload -def get_alias(obj: Type[T]) -> T: - ... +def get_alias(obj: Type[T]) -> T: ... @overload -def get_alias(obj: T) -> T: - ... +def get_alias(obj: T) -> T: ... def get_alias(obj: Union[Type[T], T]) -> T: diff --git a/apischema/ordering.py b/apischema/ordering.py index 850bbd60..39cae283 100644 --- a/apischema/ordering.py +++ b/apischema/ordering.py @@ -42,28 +42,23 @@ def __post_init__(self): @overload -def order(__value: int) -> Ordering: - ... +def order(__value: int) -> Ordering: ... @overload -def order(*, after: Any) -> Ordering: - ... +def order(*, after: Any) -> Ordering: ... @overload -def order(*, before: Any) -> Ordering: - ... +def order(*, before: Any) -> Ordering: ... @overload -def order(__fields: Sequence[Any]) -> Callable[[Cls], Cls]: - ... +def order(__fields: Sequence[Any]) -> Callable[[Cls], Cls]: ... @overload -def order(__override: Mapping[Any, Ordering]) -> Callable[[Cls], Cls]: - ... +def order(__override: Mapping[Any, Ordering]) -> Callable[[Cls], Cls]: ... def order(__arg=None, *, before=None, after=None): diff --git a/apischema/recursion.py b/apischema/recursion.py index beac1478..cdbbea59 100644 --- a/apischema/recursion.py +++ b/apischema/recursion.py @@ -151,9 +151,11 @@ def visit(self, tp: AnyType) -> Result: tp, self._conversion, self.default_conversion, - DeserializationRecursiveChecker # type: ignore - if isinstance(self, DeserializationVisitor) - else SerializationRecursiveChecker, + ( + DeserializationRecursiveChecker # type: ignore + if isinstance(self, DeserializationVisitor) + else SerializationRecursiveChecker + ), ): cache_key = tp, self._conversion if cache_key in self._cache: diff --git a/apischema/serialization/__init__.py b/apischema/serialization/__init__.py index b4f1fa8c..2dcc9e73 100644 --- a/apischema/serialization/__init__.py +++ b/apischema/serialization/__init__.py @@ -612,8 +612,7 @@ def serialize( fall_back_on_any: Optional[bool] = None, no_copy: Optional[bool] = None, pass_through: Optional[PassThroughOptions] = None, -) -> Any: - ... +) -> Any: ... @overload @@ -631,8 +630,7 @@ def serialize( fall_back_on_any: bool = True, no_copy: Optional[bool] = None, pass_through: Optional[PassThroughOptions] = None, -) -> Any: - ... +) -> Any: ... def serialize( # type: ignore diff --git a/apischema/serialization/serialized_methods.py b/apischema/serialization/serialized_methods.py index 0be5049d..602da7a3 100644 --- a/apischema/serialization/serialized_methods.py +++ b/apischema/serialization/serialized_methods.py @@ -111,8 +111,7 @@ def none_error_handler(error: Exception, obj: Any, alias: str) -> None: @overload -def serialized(__method_or_property: MethodOrProp) -> MethodOrProp: - ... +def serialized(__method_or_property: MethodOrProp) -> MethodOrProp: ... @overload @@ -124,8 +123,7 @@ def serialized( order: Optional[Ordering] = None, schema: Optional[Schema] = None, owner: Optional[Type] = None, -) -> Callable[[MethodOrProp], MethodOrProp]: - ... +) -> Callable[[MethodOrProp], MethodOrProp]: ... def serialized( diff --git a/apischema/settings.py b/apischema/settings.py index 0c847ccd..9c2440b4 100644 --- a/apischema/settings.py +++ b/apischema/settings.py @@ -43,18 +43,18 @@ def camel_case(cls, value: bool): class settings(metaclass=MetaSettings): additional_properties: bool = False aliaser: Aliaser = lambda s: s - default_object_fields: Callable[ - [type], Optional[Sequence[ObjectField]] - ] = default_object_fields_ + default_object_fields: Callable[[type], Optional[Sequence[ObjectField]]] = ( + default_object_fields_ + ) default_type_name: Callable[[AnyType], Optional[TypeName]] = default_type_name_ json_schema_version: JsonSchemaVersion = JsonSchemaVersion.DRAFT_2020_12 class base_schema: field: Callable[[AnyType, str, str], Optional[Schema]] = lambda *_: None method: Callable[[AnyType, Callable, str], Optional[Schema]] = lambda *_: None - parameter: Callable[ - [Callable, Parameter, str], Optional[Schema] - ] = lambda *_: None + parameter: Callable[[Callable, Parameter, str], Optional[Schema]] = ( + lambda *_: None + ) type: Callable[[AnyType], Optional[Schema]] = lambda *_: None class errors: diff --git a/apischema/tagged_unions.py b/apischema/tagged_unions.py index 37831b8c..c78649cb 100644 --- a/apischema/tagged_unions.py +++ b/apischema/tagged_unions.py @@ -57,12 +57,10 @@ def __post_init__(self): raise TypeError("Invalid metadata in a TaggedUnion field") @overload - def __get__(self, instance: None, owner: Type[T]) -> Tag[T, V]: - ... + def __get__(self, instance: None, owner: Type[T]) -> Tag[T, V]: ... @overload - def __get__(self, instance: Any, owner) -> Union[V, UndefinedType]: - ... + def __get__(self, instance: Any, owner) -> Union[V, UndefinedType]: ... def __get__(self, instance, owner): raise NotImplementedError diff --git a/apischema/typing.py b/apischema/typing.py index da0a34f7..0b526e58 100644 --- a/apischema/typing.py +++ b/apischema/typing.py @@ -1,4 +1,5 @@ """Kind of typing_extensions for this package""" + __all__ = ["get_args", "get_origin", "get_type_hints"] import sys diff --git a/apischema/validation/errors.py b/apischema/validation/errors.py index 5d5516d3..c686ef04 100644 --- a/apischema/validation/errors.py +++ b/apischema/validation/errors.py @@ -42,16 +42,14 @@ class LocalizedError(TypedDict): class ValidationError(Exception): @overload - def __init__(self, __message: str): - ... + def __init__(self, __message: str): ... @overload def __init__( self, messages: Optional[Sequence[ErrorMsg]] = None, children: Optional[Mapping[ErrorKey, "ValidationError"]] = None, - ): - ... + ): ... def __init__( self, @@ -89,22 +87,19 @@ def from_errors(errors: Sequence[LocalizedError]) -> "ValidationError": @overload def merge_errors( err1: Optional[ValidationError], err2: ValidationError -) -> ValidationError: - ... +) -> ValidationError: ... @overload def merge_errors( err1: ValidationError, err2: Optional[ValidationError] -) -> ValidationError: - ... +) -> ValidationError: ... @overload def merge_errors( err1: Optional[ValidationError], err2: Optional[ValidationError] -) -> Optional[ValidationError]: - ... +) -> Optional[ValidationError]: ... @merge_opts # type: ignore diff --git a/apischema/validation/validators.py b/apischema/validation/validators.py index 33dc91f2..610eda38 100644 --- a/apischema/validation/validators.py +++ b/apischema/validation/validators.py @@ -161,15 +161,13 @@ def validate( @overload -def validator(func: V) -> V: - ... +def validator(func: V) -> V: ... @overload def validator( field: Any = None, *, discard: Any = None, owner: Optional[Type] = None -) -> Callable[[V], V]: - ... +) -> Callable[[V], V]: ... def validator(arg=None, *, field=None, discard=None, owner=None): diff --git a/examples/additional_types.py b/examples/additional_types.py index 3c17fb2d..10c9c9ff 100644 --- a/examples/additional_types.py +++ b/examples/additional_types.py @@ -16,8 +16,7 @@ class Foo(Bar): baz: str -def bar() -> Bar: - ... +def bar() -> Bar: ... schema = graphql_schema(query=[bar], types=[Foo]) diff --git a/examples/base_schema_parameter.py b/examples/base_schema_parameter.py index 5368876f..083eb30c 100644 --- a/examples/base_schema_parameter.py +++ b/examples/base_schema_parameter.py @@ -38,8 +38,7 @@ def parameter_base_schema( settings.base_schema.parameter = parameter_base_schema -def foo() -> Foo: - ... +def foo() -> Foo: ... schema_ = graphql_schema(query=[foo]) diff --git a/examples/examples/sqlalchemy_support.py b/examples/examples/sqlalchemy_support.py index 21f501fb..8a4fabca 100644 --- a/examples/examples/sqlalchemy_support.py +++ b/examples/examples/sqlalchemy_support.py @@ -63,8 +63,7 @@ class Foo(Base): } -def foos() -> Collection[Foo] | None: - ... +def foos() -> Collection[Foo] | None: ... schema = graphql_schema(query=[foos]) diff --git a/examples/graphql_type_name.py b/examples/graphql_type_name.py index 8ef83ba7..efefec8e 100644 --- a/examples/graphql_type_name.py +++ b/examples/graphql_type_name.py @@ -12,8 +12,7 @@ class FooFoo: bar: int -def foo() -> FooFoo | None: - ... +def foo() -> FooFoo | None: ... schema = graphql_schema(query=[foo]) diff --git a/examples/id_type.py b/examples/id_type.py index 3d0a9c86..dbeb0126 100644 --- a/examples/id_type.py +++ b/examples/id_type.py @@ -11,8 +11,7 @@ class Foo: bar: UUID -def foo() -> Foo | None: - ... +def foo() -> Foo | None: ... # id_types={UUID} is equivalent to id_types=lambda t: t in {UUID} diff --git a/examples/interface.py b/examples/interface.py index 8a54e297..06930940 100644 --- a/examples/interface.py +++ b/examples/interface.py @@ -16,8 +16,7 @@ class Foo(Bar): baz: str -def foo() -> Foo | None: - ... +def foo() -> Foo | None: ... schema = graphql_schema(query=[foo]) diff --git a/examples/object_serialization.py b/examples/object_serialization.py index 09838817..05c1a794 100644 --- a/examples/object_serialization.py +++ b/examples/object_serialization.py @@ -15,8 +15,7 @@ class Data: def size(self) -> int: return len(self.content) - def get_details(self) -> Any: - ... + def get_details(self) -> Any: ... # Serialization fields can be a str/field or a function/method/property diff --git a/examples/operation.py b/examples/operation.py index 358515b3..b2a23f60 100644 --- a/examples/operation.py +++ b/examples/operation.py @@ -8,12 +8,10 @@ @dataclass class Foo: @resolver - async def bar(self, arg: int = 0) -> str: - ... + async def bar(self, arg: int = 0) -> str: ... -async def get_foo() -> Foo: - ... +async def get_foo() -> Foo: ... schema = graphql_schema(query=[Query(get_foo, alias="foo", error_handler=None)]) diff --git a/examples/quickstart.py b/examples/quickstart.py index b23c9027..78d641c3 100644 --- a/examples/quickstart.py +++ b/examples/quickstart.py @@ -52,8 +52,7 @@ class Resource: # Define GraphQL operations -def resources(tags: Collection[str] | None = None) -> Collection[Resource] | None: - ... +def resources(tags: Collection[str] | None = None) -> Collection[Resource] | None: ... # Generate GraphQL schema diff --git a/examples/relay_client_mutation_id.py b/examples/relay_client_mutation_id.py index fa58540d..a87fb6e1 100644 --- a/examples/relay_client_mutation_id.py +++ b/examples/relay_client_mutation_id.py @@ -6,13 +6,11 @@ @dataclass -class Ship: - ... +class Ship: ... @dataclass -class Faction: - ... +class Faction: ... @dataclass @@ -26,8 +24,7 @@ def mutate( faction_id: str, ship_name: str, mut_id: relay.ClientMutationId, - ) -> "IntroduceShip": - ... + ) -> "IntroduceShip": ... def hello() -> str: diff --git a/examples/relay_connection_subclass.py b/examples/relay_connection_subclass.py index 6fad97a2..89f971a3 100644 --- a/examples/relay_connection_subclass.py +++ b/examples/relay_connection_subclass.py @@ -33,8 +33,7 @@ class Faction: @resolver def ships( self, first: int | None, after: Cursor | None - ) -> Connection[Optional[Ship]] | None: - ... + ) -> Connection[Optional[Ship]] | None: ... def faction() -> Faction | None: diff --git a/examples/relay_mutation.py b/examples/relay_mutation.py index 4d3fbba3..0601fa2b 100644 --- a/examples/relay_mutation.py +++ b/examples/relay_mutation.py @@ -6,13 +6,11 @@ @dataclass -class Ship: - ... +class Ship: ... @dataclass -class Faction: - ... +class Faction: ... @dataclass @@ -21,8 +19,7 @@ class IntroduceShip(relay.Mutation): faction: Faction @staticmethod - def mutate(faction_id: str, ship_name: str) -> "IntroduceShip": - ... + def mutate(faction_id: str, ship_name: str) -> "IntroduceShip": ... def hello() -> str: diff --git a/examples/relay_node.py b/examples/relay_node.py index 3bbbf18d..db8836ef 100644 --- a/examples/relay_node.py +++ b/examples/relay_node.py @@ -12,8 +12,7 @@ class Ship(relay.Node[UUID]): # Let's use an UUID for Ship id name: str @classmethod - async def get_by_id(cls, id: UUID, info: graphql.GraphQLResolveInfo = None): - ... + async def get_by_id(cls, id: UUID, info: graphql.GraphQLResolveInfo = None): ... @dataclass @@ -21,8 +20,9 @@ class Faction(relay.Node[int]): # Nodes can have different id types name: str @classmethod - def get_by_id(cls, id: int, info: graphql.GraphQLResolveInfo = None) -> "Faction": - ... + def get_by_id( + cls, id: int, info: graphql.GraphQLResolveInfo = None + ) -> "Faction": ... schema = graphql_schema(query=[relay.node], types=relay.nodes()) diff --git a/examples/resolver.py b/examples/resolver.py index db1afc7d..01f6f007 100644 --- a/examples/resolver.py +++ b/examples/resolver.py @@ -13,12 +13,10 @@ class Bar: @dataclass class Foo: @resolver - async def bar(self, arg: int = 0) -> Bar: - ... + async def bar(self, arg: int = 0) -> Bar: ... -async def foo() -> Foo | None: - ... +async def foo() -> Foo | None: ... schema = graphql_schema(query=[foo]) diff --git a/examples/scalar.py b/examples/scalar.py index 415a2edb..56d50dd3 100644 --- a/examples/scalar.py +++ b/examples/scalar.py @@ -13,8 +13,7 @@ class Foo: content: Any -def foo() -> Foo | None: - ... +def foo() -> Foo | None: ... schema = graphql_schema(query=[foo]) diff --git a/examples/serialized_generic.py b/examples/serialized_generic.py index 3757b45b..0660c9b9 100644 --- a/examples/serialized_generic.py +++ b/examples/serialized_generic.py @@ -11,18 +11,15 @@ @dataclass class Foo(Generic[T]): @serialized - def bar(self) -> T: - ... + def bar(self) -> T: ... @serialized -def baz(foo: Foo[U]) -> U: - ... +def baz(foo: Foo[U]) -> U: ... @dataclass -class FooInt(Foo[int]): - ... +class FooInt(Foo[int]): ... assert ( diff --git a/examples/sub_conversions.py b/examples/sub_conversions.py index 984cfd4c..dc484fbb 100644 --- a/examples/sub_conversions.py +++ b/examples/sub_conversions.py @@ -7,16 +7,13 @@ T = TypeVar("T") -class Query(Generic[T]): - ... +class Query(Generic[T]): ... -def query_to_list(q: Query[T]) -> list[T]: - ... +def query_to_list(q: Query[T]) -> list[T]: ... -def query_to_scalar(q: Query[T]) -> T | None: - ... +def query_to_scalar(q: Query[T]) -> T | None: ... @dataclass @@ -25,8 +22,7 @@ class FooModel: class Foo: - def serialize(self) -> FooModel: - ... + def serialize(self) -> FooModel: ... assert serialization_schema( diff --git a/examples/union_type_name.py b/examples/union_type_name.py index 2f50c290..802e1ea3 100644 --- a/examples/union_type_name.py +++ b/examples/union_type_name.py @@ -15,8 +15,7 @@ class Bar: bar: int -def foo_or_bar() -> Foo | Bar: - ... +def foo_or_bar() -> Foo | Bar: ... # union_ref default value is made explicit here diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index b3bb5f96..ea894bcb 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -25,12 +25,10 @@ def test_to_camel_case(): assert to_camel_case("min_length") == "minLength" -def sync_func(): - ... +def sync_func(): ... -async def async_func(): - ... +async def async_func(): ... def func_not_returning_awaitable() -> int: # type: ignore