Add peewee playhouse.flask_utils stubs (#11731)

Co-authored-by: Avasam <samuel.06@hotmail.com>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
P M
2024-04-23 21:26:36 +02:00
committed by GitHub
parent 56db30e8eb
commit ed7f35a2bc
4 changed files with 42 additions and 0 deletions

View File

View File

@@ -0,0 +1,28 @@
from _typeshed import Unused
from collections.abc import Container
from typing import Any
from typing_extensions import TypeAlias
from peewee import Database, ModelBase, Proxy
# Is actually flask.Flask
_Flask: TypeAlias = Any
class FlaskDB:
# Omitting undocumented base_model_class on purpose, use FlaskDB.Model instead
database: Database | Proxy
def __init__(
self,
app: _Flask | None = None,
database: Database | Proxy | None = None,
# Is actually type[ModelClass] but stubtest likely confuses with Model property
# https://github.com/python/typeshed/pull/11731#issuecomment-2067694259
model_class=...,
excluded_routes: Container[str] | None = None,
) -> None: ...
def init_app(self, app: _Flask) -> None: ...
def get_model_class(self) -> type[ModelBase]: ...
@property
def Model(self) -> type[ModelBase]: ...
def connect_db(self) -> None: ...
def close_db(self, exc: Unused) -> None: ...