@@ -57,22 +57,25 @@ def decor(fn):
5757 return decor (f )
5858
5959
60+ # A lot of coverage ignoring below in the error cases - we don't test this
61+ # function specifically (if the autowalking works, this must have worked)
6062def _detect_autowalk_type_from_annot (fn ):
6163 # Warning: Introspection black magic below! May contain demons and/or dragons.
6264 try :
6365 sig = inspect .signature (fn , eval_str = True , globals = globals ())
64- except Exception as e :
66+ except Exception as e : # pragma: no cover
6567 raise TypeError ("Unable to detect node_type (cannot resolve annotations)" ) from e
6668 try :
6769 bound = sig .bind (0 , 1 ) # simulate call w/ 2 args
68- except TypeError as e :
70+ except TypeError as e : # pragma: no cover
6971 raise TypeError ("Unable to detect node_type (signature may be incompatible)" ) from e
7072 arg2_name : str = (* bound .arguments ,)[1 ] # get name it's bound to
7173 param = sig .parameters [arg2_name ] # lookup the param by name
72- if param .kind not in (param .POSITIONAL_ONLY , param .POSITIONAL_OR_KEYWORD ):
74+ if param .kind not in (param .POSITIONAL_ONLY ,
75+ param .POSITIONAL_OR_KEYWORD ): # pragma: no cover
7376 raise TypeError ("Unable to detect node_type (cannot find second positional arg)" )
7477 if not is_strict_subclass (param .annotation , (
75- NamedLeafCls , NamedNodeCls , NamedSizedNodeCls )):
78+ NamedLeafCls , NamedNodeCls , NamedSizedNodeCls )): # pragma: no cover
7679 raise TypeError ("Unable to detect node_type (annotation is not a node type)" )
7780 return param .annotation
7881
@@ -246,4 +249,4 @@ def _lookup_autowalk_fn(cls, t: type[AnyNode]):
246249 if value := _AUTOWALK_EXPR_DICT .get (supertype ):
247250 _AUTOWALK_EXPR_DICT [t ] = value # Add it as cache
248251 return value
249- raise LookupError (f"No such autowalk-er declared ({ t } )" )
252+ raise LookupError (f"No such autowalk-er declared ({ t } )" ) # pragma: no cover
0 commit comments