Get the closest parent node (including self) which is an instance of the given class. :param cls: The node class to search for. :returns: The node, if found.
(self, cls: type[_NodeType])
| 383 | self.session._setupstate.addfinalizer(fin, self) |
| 384 | |
| 385 | def getparent(self, cls: type[_NodeType]) -> _NodeType | None: |
| 386 | """Get the closest parent node (including self) which is an instance of |
| 387 | the given class. |
| 388 | |
| 389 | :param cls: The node class to search for. |
| 390 | :returns: The node, if found. |
| 391 | """ |
| 392 | for node in self.iter_parents(): |
| 393 | if isinstance(node, cls): |
| 394 | return node |
| 395 | return None |
| 396 | |
| 397 | def _traceback_filter(self, excinfo: ExceptionInfo[BaseException]) -> Traceback: |
| 398 | return excinfo.traceback |