style fix

This commit is contained in:
AF 2023-08-25 09:16:41 +00:00
parent f1692effcf
commit 0794a9392d

View File

@ -4,7 +4,7 @@ import functools
from contextlib import ExitStack from contextlib import ExitStack
from typing import Callable, Self from typing import Callable, Self
__all__ = ('Instrumentation',) __all__ = ("Instrumentation",)
class Instrumentation: class Instrumentation:
@ -14,9 +14,9 @@ class Instrumentation:
def __init__(self, target, methodname: str): def __init__(self, target, methodname: str):
if not isinstance(methodname, str): if not isinstance(methodname, str):
raise TypeError('methodname must be str') raise TypeError("methodname must be str")
if not callable(getattr(target, methodname)): if not callable(getattr(target, methodname)):
raise TypeError('target.methodname must be callable') raise TypeError("target.methodname must be callable")
self.target = target self.target = target
self.methodname = methodname self.methodname = methodname
@ -24,7 +24,7 @@ class Instrumentation:
return method(*args, **kwargs) return method(*args, **kwargs)
def __enter__(self) -> Self: def __enter__(self) -> Self:
if hasattr(self, '_method') or hasattr(self, '_wrap'): if hasattr(self, "_method") or hasattr(self, "_wrap"):
raise RuntimeError raise RuntimeError
method = getattr(self.target, self.methodname) method = getattr(self.target, self.methodname)
if not callable(method): if not callable(method):