22from operator import attrgetter
33from typing import Any
44from typing import Generator
5+ from typing import Tuple
56
67from .signature import SignatureAdapter
78
@@ -15,7 +16,7 @@ class ObjectConfig(namedtuple("ObjectConfig", "obj skip_attrs resolver_id")):
1516 """
1617
1718 @classmethod
18- def from_obj (cls , obj , skip_attrs = None ):
19+ def from_obj (cls , obj , skip_attrs = None ) -> "ObjectConfig" :
1920 if isinstance (obj , ObjectConfig ):
2021 return obj
2122 else :
@@ -84,7 +85,7 @@ async def wrapper(*args, **kwargs):
8485
8586
8687def _search_callable_attr_is_property (
87- attr , configs : tuple [ObjectConfig ]
88+ attr , configs : Tuple [ObjectConfig , ... ]
8889) -> "WrapSearchResult | None" :
8990 # if the attr is a property, we'll try to find the object that has the
9091 # property on the configs
@@ -96,7 +97,7 @@ def _search_callable_attr_is_property(
9697 return None
9798
9899
99- def _search_callable_attr_is_callable (attr , configs : tuple [ObjectConfig ]) -> WrapSearchResult :
100+ def _search_callable_attr_is_callable (attr , configs : Tuple [ObjectConfig , ... ]) -> WrapSearchResult :
100101 # if the attr is an unbounded method, we'll try to find the bounded method
101102 # on the configs
102103 if not hasattr (attr , "__self__" ):
@@ -109,7 +110,7 @@ def _search_callable_attr_is_callable(attr, configs: tuple[ObjectConfig]) -> Wra
109110
110111
111112def _search_callable_in_configs (
112- attr , configs : tuple [ObjectConfig ]
113+ attr , configs : Tuple [ObjectConfig , ... ]
113114) -> Generator [WrapSearchResult , None , None ]:
114115 for obj , skip_attrs , resolver_id in configs :
115116 if attr in skip_attrs :
@@ -128,7 +129,9 @@ def _search_callable_in_configs(
128129 yield CallableSearchResult (attr , func , resolver_id )
129130
130131
131- def search_callable (attr , configs : tuple ) -> Generator [WrapSearchResult , None , None ]: # noqa: C901
132+ def search_callable (
133+ attr , configs : Tuple [ObjectConfig , ...]
134+ ) -> Generator [WrapSearchResult , None , None ]: # noqa: C901
132135 if isinstance (attr , property ):
133136 result = _search_callable_attr_is_property (attr , configs )
134137 if result is not None :
@@ -142,7 +145,7 @@ def search_callable(attr, configs: tuple) -> Generator[WrapSearchResult, None, N
142145 yield from _search_callable_in_configs (attr , configs )
143146
144147
145- def resolver_factory (objects : tuple [ObjectConfig ]):
148+ def resolver_factory (objects : Tuple [ObjectConfig , ... ]):
146149 """Factory that returns a configured resolver."""
147150
148151 def resolver (attr ) -> Generator [WrapSearchResult , None , None ]:
@@ -151,6 +154,6 @@ def resolver(attr) -> Generator[WrapSearchResult, None, None]:
151154 return resolver
152155
153156
154- def resolver_factory_from_objects (* objects : tuple [Any ]):
155- configs = tuple (ObjectConfig .from_obj (o ) for o in objects )
157+ def resolver_factory_from_objects (* objects : Tuple [Any , ... ]):
158+ configs : Tuple [ ObjectConfig , ...] = tuple (ObjectConfig .from_obj (o ) for o in objects )
156159 return resolver_factory (configs )
0 commit comments