Skip to content

Commit

Permalink
Some lint fixes (#3578)
Browse files Browse the repository at this point in the history
* lint

* T

* T
  • Loading branch information
patrick91 authored Jul 23, 2024
1 parent 3389c66 commit 494d540
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 15 deletions.
1 change: 0 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def tests_typecheckers(session: Session) -> None:

session.install("pyright")
session.install("pydantic")
session.install("git+https://github.com/python/mypy.git#master")

session.run(
"pytest",
Expand Down
2 changes: 1 addition & 1 deletion strawberry/printer/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _serialize_dataclasses(value: object) -> object: ...

def _serialize_dataclasses(value):
if dataclasses.is_dataclass(value):
return dataclasses.asdict(value)
return dataclasses.asdict(value) # type: ignore
if isinstance(value, (list, tuple)):
return [_serialize_dataclasses(v) for v in value]
if isinstance(value, dict):
Expand Down
2 changes: 1 addition & 1 deletion strawberry/relay/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async def resolve(resolved: Any = resolved_nodes) -> List[Node]:
await asyncio.gather(
*awaitable_nodes.values(),
*(
asyncgen_to_list(nodes)
asyncgen_to_list(nodes) # type: ignore
for nodes in asyncgen_nodes.values()
),
),
Expand Down
2 changes: 1 addition & 1 deletion strawberry/relay/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def resolve_node(self, info, *, required=False, ensure_type=None) -> Any:
"""
n_type = self.resolve_type(info)
node = cast(
node: Node | Awaitable[Node] = cast(
Awaitable[Node],
n_type.resolve_node(
self.node_id,
Expand Down
8 changes: 1 addition & 7 deletions strawberry/schema/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from inspect import isawaitable
from typing import (
TYPE_CHECKING,
Awaitable,
Callable,
Iterable,
List,
Expand All @@ -14,7 +13,6 @@
Type,
TypedDict,
Union,
cast,
)

from graphql import GraphQLError, parse
Expand All @@ -32,7 +30,6 @@
from typing_extensions import NotRequired, Unpack

from graphql import ExecutionContext as GraphQLExecutionContext
from graphql import ExecutionResult as GraphQLExecutionResult
from graphql import GraphQLSchema
from graphql.language import DocumentNode
from graphql.validation import ASTValidationRule
Expand Down Expand Up @@ -139,9 +136,8 @@ async def execute(
)

if isawaitable(result):
result = await cast(Awaitable["GraphQLExecutionResult"], result)
result = await result

result = cast("GraphQLExecutionResult", result)
execution_context.result = result
# Also set errors on the execution_context so that it's easier
# to access in extensions
Expand Down Expand Up @@ -237,13 +233,11 @@ def execute_sync(
)

if isawaitable(result):
result = cast(Awaitable["GraphQLExecutionResult"], result)
ensure_future(result).cancel()
raise RuntimeError(
"GraphQL execution failed to complete synchronously."
)

result = cast("GraphQLExecutionResult", result)
execution_context.result = result
# Also set errors on the execution_context so that it's easier
# to access in extensions
Expand Down
2 changes: 1 addition & 1 deletion strawberry/types/lazy_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __class_getitem__(cls, params: Tuple[str, str]) -> "Self":

return cls(type_name, module, package)

def __or__(self, other: Other) -> Union[Self, Other]:
def __or__(self, other: Other) -> object:
return Union[self, other]

def resolve_type(self) -> Type[Any]:
Expand Down
4 changes: 2 additions & 2 deletions strawberry/utils/await_maybe.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import inspect
from typing import AsyncIterator, Awaitable, Iterator, TypeVar, Union, cast
from typing import AsyncIterator, Awaitable, Iterator, TypeVar, Union

T = TypeVar("T")

Expand All @@ -11,7 +11,7 @@ async def await_maybe(value: AwaitableOrValue[T]) -> T:
if inspect.isawaitable(value):
return await value

return cast(T, value)
return value


__all__ = ["await_maybe", "AwaitableOrValue", "AsyncIteratorOrIterator"]
2 changes: 1 addition & 1 deletion strawberry/utils/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def _ast_replace_union_operation(
expr = ast.Subscript(
expr.value,
# The cast is required for mypy on python 3.7 and 3.8
ast.Index(_ast_replace_union_operation(cast(Any, expr.slice).value)),
ast.Index(_ast_replace_union_operation(cast(Any, expr.slice).value)), # type: ignore
ast.Load(),
)
elif isinstance(expr.slice, (ast.BinOp, ast.Tuple)):
Expand Down

0 comments on commit 494d540

Please sign in to comment.