style fix
This commit is contained in:
		
							parent
							
								
									f1692effcf
								
							
						
					
					
						commit
						0794a9392d
					
				@ -4,7 +4,7 @@ import functools
 | 
			
		||||
from contextlib import ExitStack
 | 
			
		||||
from typing import Callable, Self
 | 
			
		||||
 | 
			
		||||
__all__ = ('Instrumentation',)
 | 
			
		||||
__all__ = ("Instrumentation",)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Instrumentation:
 | 
			
		||||
@ -14,9 +14,9 @@ class Instrumentation:
 | 
			
		||||
 | 
			
		||||
    def __init__(self, target, 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)):
 | 
			
		||||
            raise TypeError('target.methodname must be callable')
 | 
			
		||||
            raise TypeError("target.methodname must be callable")
 | 
			
		||||
        self.target = target
 | 
			
		||||
        self.methodname = methodname
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,7 @@ class Instrumentation:
 | 
			
		||||
        return method(*args, **kwargs)
 | 
			
		||||
 | 
			
		||||
    def __enter__(self) -> Self:
 | 
			
		||||
        if hasattr(self, '_method') or hasattr(self, '_wrap'):
 | 
			
		||||
        if hasattr(self, "_method") or hasattr(self, "_wrap"):
 | 
			
		||||
            raise RuntimeError
 | 
			
		||||
        method = getattr(self.target, self.methodname)
 | 
			
		||||
        if not callable(method):
 | 
			
		||||
@ -59,7 +59,7 @@ class Instrumentation:
 | 
			
		||||
 | 
			
		||||
    def enter(self, stack: ExitStack) -> Self:
 | 
			
		||||
        return stack.enter_context(self)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def enter_conditional(self, stack: ExitStack) -> Self | None:
 | 
			
		||||
        if hasattr(self.target, self.methodname):
 | 
			
		||||
            return self.enter(stack)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user