diff --git a/strawberry/codegen/plugins/python.py b/strawberry/codegen/plugins/python.py index 7eeb41111d..4af4cb0cbf 100644 --- a/strawberry/codegen/plugins/python.py +++ b/strawberry/codegen/plugins/python.py @@ -65,7 +65,7 @@ def generate_code( def _print_imports(self) -> str: imports = [ - f'from {import_} import {", ".join(sorted(types))}' + f"from {import_} import {', '.join(sorted(types))}" for import_, types in self.imports.items() ] @@ -187,9 +187,9 @@ def _print_scalar_type(self, type_: GraphQLScalar) -> str: if type_.name in self.SCALARS_TO_PYTHON_TYPES: return "" - assert ( - type_.python_type is not None - ), f"Scalar type must have a python type: {type_.name}" + assert type_.python_type is not None, ( + f"Scalar type must have a python type: {type_.name}" + ) return f'{type_.name} = NewType("{type_.name}", {type_.python_type.__name__})' diff --git a/strawberry/codegen/query_codegen.py b/strawberry/codegen/query_codegen.py index 8f0ecffef7..768f334466 100644 --- a/strawberry/codegen/query_codegen.py +++ b/strawberry/codegen/query_codegen.py @@ -347,9 +347,9 @@ def _populate_fragment_types(self, ast: DocumentNode) -> None: ) for fd in fragment_definitions: query_type = self.schema.get_type_by_name(fd.type_condition.name.value) - assert isinstance( - query_type, StrawberryObjectDefinition - ), f"{fd.type_condition.name.value!r} is not a type in the graphql schema!" + assert isinstance(query_type, StrawberryObjectDefinition), ( + f"{fd.type_condition.name.value!r} is not a type in the graphql schema!" + ) typename = fd.type_condition.name.value graph_ql_object_type_factory = partial( @@ -695,9 +695,9 @@ def _field_from_selection_set( selection.name.value, parent_type_name ) - assert ( - selected_field - ), f"Couldn't find {parent_type_name}.{selection.name.value}" + assert selected_field, ( + f"Couldn't find {parent_type_name}.{selection.name.value}" + ) selected_field_type, wrapper = self._unwrap_type(selected_field.type) name = capitalize_first(to_camel_case(selection.name.value)) diff --git a/strawberry/exceptions/missing_return_annotation.py b/strawberry/exceptions/missing_return_annotation.py index 60d64bffa0..4b863c84f7 100644 --- a/strawberry/exceptions/missing_return_annotation.py +++ b/strawberry/exceptions/missing_return_annotation.py @@ -27,7 +27,7 @@ def __init__( "did you forget to add it?" ) self.rich_message = ( - "[bold red]Missing annotation for field " f"`[underline]{resolver.name}[/]`" + f"[bold red]Missing annotation for field `[underline]{resolver.name}[/]`" ) self.suggestion = ( diff --git a/strawberry/exceptions/permission_fail_silently_requires_optional.py b/strawberry/exceptions/permission_fail_silently_requires_optional.py index ca3a7de713..16bb1494cf 100644 --- a/strawberry/exceptions/permission_fail_silently_requires_optional.py +++ b/strawberry/exceptions/permission_fail_silently_requires_optional.py @@ -16,7 +16,7 @@ class PermissionFailSilentlyRequiresOptionalError(StrawberryException): def __init__(self, field: StrawberryField) -> None: self.field = field self.message = ( - "Cannot use fail_silently=True with a non-optional " "or non-list field" + "Cannot use fail_silently=True with a non-optional or non-list field" ) self.rich_message = ( "fail_silently permissions can only be used with fields of type " diff --git a/strawberry/printer/ast_from_value.py b/strawberry/printer/ast_from_value.py index eb2da54853..d4e23294ca 100644 --- a/strawberry/printer/ast_from_value.py +++ b/strawberry/printer/ast_from_value.py @@ -56,8 +56,7 @@ def ast_from_leaf_type( return IntValueNode(value=str(serialized)) if isinstance(serialized, float) and isfinite(serialized): value = str(serialized) - if value.endswith(".0"): - value = value[:-2] + value = value.removesuffix(".0") return FloatValueNode(value=value) if isinstance(serialized, str): diff --git a/strawberry/schema/schema_converter.py b/strawberry/schema/schema_converter.py index 000d384934..332a9bdb5f 100644 --- a/strawberry/schema/schema_converter.py +++ b/strawberry/schema/schema_converter.py @@ -518,12 +518,10 @@ def from_interface( assert isinstance(graphql_interface, GraphQLInterfaceType) # For mypy return graphql_interface - def _get_resolve_type() -> ( - Callable[ - [Any, GraphQLResolveInfo, GraphQLAbstractType], - Union[Awaitable[Optional[str]], str, None], - ] - ): + def _get_resolve_type() -> Callable[ + [Any, GraphQLResolveInfo, GraphQLAbstractType], + Union[Awaitable[Optional[str]], str, None], + ]: if interface.resolve_type: return interface.resolve_type diff --git a/tests/litestar/test_response_headers.py b/tests/litestar/test_response_headers.py index a606e9ad03..7a70045841 100644 --- a/tests/litestar/test_response_headers.py +++ b/tests/litestar/test_response_headers.py @@ -59,6 +59,5 @@ def abc(self, info: strawberry.Info) -> str: assert response.json() == {"data": {"abc": "abc"}} assert response.headers["set-cookie"] == ( - "strawberry=rocks; Path=/; SameSite=lax, " - "Litestar=rocks; Path=/; SameSite=lax" + "strawberry=rocks; Path=/; SameSite=lax, Litestar=rocks; Path=/; SameSite=lax" ) diff --git a/tests/schema/test_basic.py b/tests/schema/test_basic.py index 1f63c86084..77cbf5605b 100644 --- a/tests/schema/test_basic.py +++ b/tests/schema/test_basic.py @@ -476,9 +476,9 @@ class Query: } """ assert str(schema) == textwrap.dedent(expected).strip() - assert " list[int]: with pytest.raises( WrongNumberOfResultsReturned, match=( - "Received wrong number of results in dataloader, " - "expected: 1, received: 2" + "Received wrong number of results in dataloader, expected: 1, received: 2" ), ): await loader.load(1)