Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/hupper/interfaces.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from abc import ABC as ABC, abstractmethod as abstractmethod
from collections.abc import Callable as _Callable, Iterable as _Iterable

class IReloaderProxy(ABC):
@abstractmethod
def watch_files(self, files: _Iterable[str]) -> None: ...
@abstractmethod
def trigger_reload(self) -> None: ...
@abstractmethod
def graceful_shutdown(self) -> None: ...

class IFileMonitorFactory(ABC):
@abstractmethod
def __call__(
self,
callback: _Callable[[str], None],
**kw: object,
) -> IFileMonitor: ...

class IFileMonitor(ABC):
@abstractmethod
def add_path(self, path: str) -> None: ...
@abstractmethod
def start(self) -> None: ...
@abstractmethod
def stop(self) -> None: ...
@abstractmethod
def join(self) -> None: ...

class ILogger(ABC):
@abstractmethod
def error(self, msg: str) -> None: ...
@abstractmethod
def info(self, msg: str) -> None: ...
@abstractmethod
def debug(self, msg: str) -> None: ...
20 changes: 20 additions & 0 deletions src/hupper/logger.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys as sys

from .interfaces import ILogger as ILogger

class LogLevel:
ERROR: int
INFO: int
DEBUG: int

class DefaultLogger(ILogger):
level: int
def __init__(self, level: int) -> None: ...
def error(self, msg: str) -> None: ...
def info(self, msg: str) -> None: ...
def debug(self, msg: str) -> None: ...

class SilentLogger(ILogger):
def error(self, msg: str) -> None: ...
def info(self, msg: str) -> None: ...
def debug(self, msg: str) -> None: ...
27 changes: 27 additions & 0 deletions src/hupper/polling.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from _thread import LockType as _LockType
from collections.abc import Callable as _Callable, Iterable as _Iterable
import os as os
import threading as threading
import time as time

from .interfaces import IFileMonitor as IFileMonitor

class PollingFileMonitor(threading.Thread, IFileMonitor):
callback: _Callable[[str], None]
poll_interval: float
paths: set[str]
mtimes: dict[str, float]
lock: _LockType
enabled: bool
def __init__(
self,
callback: _Callable[[str], None],
interval: float = 1,
**kw: object,
) -> None: ...
def add_path(self, path: str) -> None: ...
def run(self) -> None: ...
def stop(self) -> None: ...
def check_reload(self, paths: _Iterable[str]) -> None: ...

def get_mtime(path: str) -> float: ...
Empty file added src/hupper/py.typed
Empty file.
26 changes: 26 additions & 0 deletions src/hupper/utils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import importlib as importlib
import json as json
import os as os
import subprocess as subprocess
import sys as sys
from typing import Protocol as _Protocol

class _InteractiveStream(_Protocol):
def isatty(self) -> bool: ...

WIN: bool

class Sentinel:
name: object
def __init__(self, name: object) -> None: ...
def __repr__(self) -> str: ...

default: Sentinel

def resolve_spec(spec: str) -> object: ...
def is_watchdog_supported() -> bool: ...
def is_watchman_supported() -> bool: ...
def get_watchman_sockpath(binpath: str = "watchman") -> str: ...
def is_stream_interactive(
stream: _InteractiveStream | None,
) -> bool: ...