typestubs/asfquart/base.pyi (40 lines of code) (raw):
"""
This type stub file was generated by pyright.
"""
import quart
"""ASFQuart - Base application/event-loop module.
USAGE:
main.py:
import asfquart
APP = asfquart.construct('selfserve')
anywhere else:
import asfquart
APP = asfquart.APP
Quart.app defines a "name" property which can be used as an APP "ID"
(eg. discriminator for cookies). While most Quart apps use the module
name for this (and internally Quart calls this .import_name), it can
be anything and the .name property treats it as arbitrary.
"""
LOGGER = ...
SECRETS_FILE_MODE = ...
SECRETS_FILE_UMASK = ...
CONFIG_FNAME = ...
class ASFQuartException(Exception):
"""Global ASFQuart exception with a message and an error code, for the HTTP response."""
def __init__(self, message: str = ..., errorcode: int = ...) -> None: ...
class QuartApp(quart.Quart):
"""Subclass of quart.Quart to include our specific features."""
def __init__(self, app_id, *args, **kw) -> None: ...
def runx(
self,
/,
host=...,
port=...,
debug=...,
loop=...,
certfile=...,
keyfile=...,
extra_files=...,
): # -> None:
"""Extended version of Quart.run()
LOOP is the loop this app should run within. One will be constructed,
if this is not provided.
EXTRA_FILES is a set of files (### relative to?) that should be
watched for changes. If a change occurs, the app will be reloaded.
"""
...
def factory_trigger(self, loop, extra_files=...): # -> Callable[[], Coroutine[Any, Any, None]]:
"""Factory for an AWAITABLE that handles special exceptions.
The LOOP normally ignores all signals. This method will make the
loop catch SIGTERM/SIGINT, then set an Event to raise an exception
for a clean exit.
This will also observe files for changes, and signal the loop
to reload the application.
"""
...
async def watch(self, extra_files=...): # -> None:
"Watch all known .py files, plus some extra files (eg. configs)."
...
def run_forever(self, loop, task): # -> None:
"Run the application until exit, then cleanly shut down."
...
def load_template(self, tpath, base_format=...): # -> Template:
...
def use_template(
self, path_or_T, base_format=...
): # -> Callable[..., _Wrapped[Callable[..., Any], Any, Callable[..., Any], Coroutine[Any, Any, str]]]:
...
def add_runner(self, func, name=...): # -> None:
"Add a long-running task, with cancellation/cleanup."
...
def construct(name, *args, **kw): # -> QuartApp:
...