diff --git a/sysaudit/__init__.py b/sysaudit/__init__.py index 34a454d..ffbf0b9 100644 --- a/sysaudit/__init__.py +++ b/sysaudit/__init__.py @@ -110,8 +110,7 @@ class Span: self.message("annotate", data) def __enter__(self): - self.start() - return self + return self.start() def __exit__(self, exc_type, exc_val, exc_tb): self.end(data=dict(exc_type=exc_type, exc_val=exc_val, exc_tb=exc_tb)) diff --git a/sysaudit/__init__.pyi b/sysaudit/__init__.pyi index cd66550..e8e12ec 100644 --- a/sysaudit/__init__.pyi +++ b/sysaudit/__init__.pyi @@ -1,6 +1,47 @@ +import types import typing def audit(event: str, *args: typing.Any) -> None: ... def addaudithook( hook: typing.Callable[[str, typing.Tuple[typing.Any, ...]], None] ) -> None: ... +def _subscription_hook(event: str, args: typing.Tuple[typing.Any, ...]) -> None: ... +def subscribe( + event: str, hook: typing.Callable[[typing.Tuple[typing.Any, ...]], None] +) -> None: ... + +class Span: + # Properties + name: str + started: bool + ended: bool + data: typing.Optional[typing.Any] = None + + # Span.Message class + class Message: + # Properties + type: str + span: Span + data: typing.Optional[typing.Any] = None + + # Methods + def __init__( + self, type: str, span: Span, data: typing.Optional[typing.Any] = None + ): ... + def __str__(self) -> str: ... + # Methods + def __init__(self, name: str, data: typing.Optional[typing.Any] = None): ... + @property + def id(self) -> int: ... + def message(self, type: str, data: typing.Optional[typing.Any] = None) -> None: ... + def start(self, data: typing.Optional[typing.Any] = None) -> Span: ... + def end(self, data: typing.Optional[typing.Any] = None) -> None: ... + def annotate(self, data: typing.Any) -> None: ... + def __enter__(self) -> Span: ... + def __exit__( + self, + exc_type: typing.Optional[typing.Type[BaseException]], + exc_val: typing.Optional[BaseException], + exc_tb: typing.Optional[types.TracebackType], + ) -> None: ... + def __str__(self) -> str: ...