Skip to content

Commit

Permalink
fix: fix mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bellini666 committed Dec 26, 2024
1 parent a63500a commit 275148b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions strawberry/codegen/plugins/typescript.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def _print_scalar_type(self, type_: GraphQLScalar) -> str:
if type_.name in self.SCALARS_TO_TS_TYPE:
return ""

assert type_.python_type is not None
return f"type {type_.name} = {self.SCALARS_TO_TS_TYPE[type_.python_type]}"

def _print_union_type(self, type_: GraphQLUnion) -> str:
Expand Down
14 changes: 8 additions & 6 deletions strawberry/extensions/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,22 @@ def from_callable(
func: Callable[[SchemaExtension], AwaitableOrValue[Any]],
) -> WrappedHook:
if iscoroutinefunction(func):
is_async = True

@contextlib.asynccontextmanager
async def iterator() -> AsyncIterator[None]:
await func(extension)
yield

return WrappedHook(extension=extension, hook=iterator, is_async=True)
else:
is_async = False

@contextlib.contextmanager
def iterator() -> Iterator[None]:
func(extension)
yield
@contextlib.contextmanager
def iterator() -> Iterator[None]:
func(extension)
yield

return WrappedHook(extension=extension, hook=iterator, is_async=False)
return WrappedHook(extension=extension, hook=iterator, is_async=is_async)

def __enter__(self) -> None:
self.exit_stack = contextlib.ExitStack()
Expand Down
2 changes: 1 addition & 1 deletion strawberry/federation/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def _add_link_directives(
link_directives: list[object] = [
Link(
url=url,
import_=sorted(directives),
import_=sorted(directives), # type: ignore[arg-type]
)
for url, directives in directive_by_url.items()
]
Expand Down
4 changes: 2 additions & 2 deletions strawberry/litestar/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class GraphQLController(
],
):
path: str = ""
dependencies: ClassVar[Dependencies] = {
dependencies: ClassVar[Dependencies] = { # type: ignore[misc]
"custom_context": Provide(_none_custom_context_getter),
"context": Provide(_context_getter_http),
"context_ws": Provide(_context_getter_ws),
Expand Down Expand Up @@ -446,7 +446,7 @@ def make_graphql_controller(

class _GraphQLController(GraphQLController):
path: str = routes_path
dependencies: ClassVar[Dependencies] = {
dependencies: ClassVar[Dependencies] = { # type: ignore[misc]
"custom_context": Provide(custom_context_getter_),
"context": Provide(_context_getter_http),
"context_ws": Provide(_context_getter_ws),
Expand Down
2 changes: 1 addition & 1 deletion strawberry/types/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from strawberry.types.enum import EnumDefinition
from strawberry.types.lazy_type import LazyType, StrawberryLazyReference
from strawberry.types.unset import UNSET as _deprecated_UNSET # noqa: N811
from strawberry.types.unset import _deprecated_is_unset # type: ignore # noqa: F401
from strawberry.types.unset import _deprecated_is_unset # noqa: F401

if TYPE_CHECKING:
from strawberry.schema.config import StrawberryConfig
Expand Down
2 changes: 1 addition & 1 deletion strawberry/utils/graphql_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GraphQLLexer(RegexLexer):
filenames: ClassVar[list[str]] = ["*.graphql", "*.gql"]
mimetypes: ClassVar[list[str]] = ["application/graphql"]

tokens: ClassVar[dict[str, tuple[str, Any]]] = {
tokens: ClassVar[dict[str, list[tuple[str, Any]]]] = {
"root": [
(r"#.*", token.Comment.Singline),
(r"\.\.\.", token.Operator),
Expand Down

0 comments on commit 275148b

Please sign in to comment.