Check the value of given annotation (argument name) in the prim_func decorator. Returns the value of the annotation if present, otherwise giving the default value.
(node: doc.FunctionDef, annotation: str, default: bool = True)
| 238 | |
| 239 | |
| 240 | def find_decorator_annotation(node: doc.FunctionDef, annotation: str, default: bool = True) -> bool: |
| 241 | """ |
| 242 | Check the value of given annotation (argument name) in the prim_func decorator. |
| 243 | Returns the value of the annotation if present, otherwise giving the default value. |
| 244 | """ |
| 245 | # look for the named argument in the prim_func / jit decorator |
| 246 | for dec in node.decorator_list: |
| 247 | if not isinstance(dec, doc.Call) or dec.func.attr not in ("prim_func", "jit"): |
| 248 | continue |
| 249 | for keyword in dec.keywords: |
| 250 | if keyword.arg == annotation: |
| 251 | return keyword.value.value |
| 252 | return default |
| 253 | |
| 254 | |
| 255 | @dispatch.register(token="tirx", type_name="For") |
no outgoing calls
no test coverage detected
searching dependent graphs…