enter_conditional

This commit is contained in:
AF 2022-11-04 09:38:59 +00:00
parent add1e7cdbf
commit e9fba7b064

View File

@ -58,3 +58,10 @@ class Instrumentation(Generic[IType]):
def enter(self: IType, stack: ExitStack) -> IType:
assert isinstance(self, Instrumentation)
return stack.enter_context(self)
def enter_conditional(self: IType, stack: ExitStack) -> IType | None:
assert isinstance(self, Instrumentation)
if hasattr(self.target, self.methodname):
return self.enter(stack)
else:
return None