Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#3752)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Thiago Bellini Ribeiro <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and bellini666 authored Jan 15, 2025
1 parent eb12310 commit 9931cf6
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.1
hooks:
- id: ruff-format
exclude: ^tests/\w+/snapshots/
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ ignore = [
"A001",
"A002",
"A003",
"A005",

# Unused arguments
"ARG001",
Expand Down
8 changes: 4 additions & 4 deletions strawberry/codegen/plugins/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]

Expand Down Expand Up @@ -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__})'

Expand Down
12 changes: 6 additions & 6 deletions strawberry/codegen/query_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion strawberry/exceptions/missing_return_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
3 changes: 1 addition & 2 deletions strawberry/printer/ast_from_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 4 additions & 6 deletions strawberry/schema/schema_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion strawberry/schema/types/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _get_scalar_definition(scalar: type) -> ScalarDefinition:
GlobalID,
name="GlobalID",
description=GraphQLID.description,
parse_literal=lambda v, vars=None: GlobalID.from_id(
parse_literal=lambda v, vars=None: GlobalID.from_id( # noqa: A006
GraphQLID.parse_literal(v, vars)
),
parse_value=GlobalID.from_id,
Expand Down
3 changes: 1 addition & 2 deletions tests/litestar/test_response_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
6 changes: 3 additions & 3 deletions tests/schema/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,9 @@ class Query:
}
"""
assert str(schema) == textwrap.dedent(expected).strip()
assert "<strawberry.schema.schema.Schema object" in repr(
schema
), "Repr should not be affected"
assert "<strawberry.schema.schema.Schema object" in repr(schema), (
"Repr should not be affected"
)


def test_field_with_default():
Expand Down
4 changes: 2 additions & 2 deletions tests/schema/test_one_of.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_must_specify_at_least_one_key_literal(value: str, variables: dict[str,
variables_definitions.append("$input: ExampleInputTagged!")

variables_definition_str = (
f'({", ".join(variables_definitions)})' if variables_definitions else ""
f"({', '.join(variables_definitions)})" if variables_definitions else ""
)

query = f"""
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_works(value: str, variables: dict[str, Any], expected: dict[str, Any]):
variables_definitions.append("$input: ExampleInputTagged!")

variables_definition_str = (
f'({", ".join(variables_definitions)})' if variables_definitions else ""
f"({', '.join(variables_definitions)})" if variables_definitions else ""
)

field = next(iter(expected.keys()))
Expand Down
2 changes: 1 addition & 1 deletion tests/schema/types/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def datetime_input(
"20120411T03:30-25:40",
"20120411T03:30+00:60",
"20120411T03:30+00:61",
"20120411T033030.123456012:00" "2014-03-12T12:30:14",
"20120411T033030.123456012:002014-03-12T12:30:14",
"2014-04-21T24:00:01",
],
)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ async def idx(keys: list[int]) -> 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)
Expand Down

0 comments on commit 9931cf6

Please sign in to comment.