Skip to content

Commit

Permalink
Improve resolver typings
Browse files Browse the repository at this point in the history
  • Loading branch information
karol-gruszczyk committed Mar 16, 2018
1 parent 1824670 commit 808cf4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 9 additions & 4 deletions slothql/types/fields/resolver.py
@@ -1,18 +1,23 @@
import inspect
import functools
from typing import Callable, Dict, Optional, Any
from typing import Callable, Dict, Optional, Any, Union

import graphql
from graphql.language.ast import Value

from slothql.utils.functional import is_method, get_function_signature

ResolveArgs = Dict[str, Value]
PartialResolver = Callable[[Optional[Any], Optional[graphql.ResolveInfo], Optional[ResolveArgs]], Callable]
Resolver = Callable[[Any, graphql.ResolveInfo, ResolveArgs], Callable]
PartialResolver = Union[
Callable[[Any, graphql.ResolveInfo, ResolveArgs], Any],
Callable[[Any, graphql.ResolveInfo], Any],
Callable[[Any], Any],
Callable[[], Any],
]
Resolver = Callable[[Any, graphql.ResolveInfo, ResolveArgs], Any]


def _get_function(field, resolver: PartialResolver = None) -> Optional[Resolver]:
def _get_function(field, resolver: PartialResolver = None) -> Optional[PartialResolver]:
if resolver is None:
return None
if isinstance(resolver, staticmethod):
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Expand Up @@ -13,7 +13,6 @@ omit =
exclude_lines =
pass
def __repr__
assert
raise NotImplementedError

[flake8]
Expand Down

0 comments on commit 808cf4f

Please sign in to comment.