From d834c24e141c0d692710b459fe82204785ef9a34 Mon Sep 17 00:00:00 2001 From: timofey Date: Fri, 13 Jan 2023 15:33:49 +0000 Subject: [PATCH] remove generic from instrumentation --- rainbowadn/instrument/instrumentation.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rainbowadn/instrument/instrumentation.py b/rainbowadn/instrument/instrumentation.py index fe65171..6bf3ba8 100644 --- a/rainbowadn/instrument/instrumentation.py +++ b/rainbowadn/instrument/instrumentation.py @@ -1,13 +1,13 @@ import functools from contextlib import ExitStack -from typing import Callable, Generic, TypeVar +from typing import Callable, TypeVar __all__ = ('Instrumentation',) -IType = TypeVar('IType') +IType = TypeVar('IType', bound='Instrumentation') -class Instrumentation(Generic[IType]): +class Instrumentation: deinstrumentation = {} _method: Callable _wrap: Callable @@ -24,8 +24,6 @@ class Instrumentation(Generic[IType]): raise NotImplementedError def __enter__(self: IType) -> IType: - if not isinstance(self, Instrumentation): - raise TypeError if hasattr(self, '_method') or hasattr(self, '_wrap'): raise RuntimeError method = getattr(self.target, self.methodname)