Browse Source

add type definitions for subscription/span api

pull/1/head
Brett Langdon 5 years ago
parent
commit
2e2b4e8d67
Signed by: brettlangdon GPG Key ID: A70042D88B95AA2B
2 changed files with 42 additions and 2 deletions
  1. +1
    -2
      sysaudit/__init__.py
  2. +41
    -0
      sysaudit/__init__.pyi

+ 1
- 2
sysaudit/__init__.py View File

@ -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))


+ 41
- 0
sysaudit/__init__.pyi View File

@ -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: ...

Loading…
Cancel
Save