diff --git a/flask_bootstrap/__init__.py b/flask_bootstrap/__init__.py index a71b8a6..a99e7b4 100644 --- a/flask_bootstrap/__init__.py +++ b/flask_bootstrap/__init__.py @@ -1,9 +1,12 @@ import warnings +from typing import NoReturn, ParamSpec from flask import current_app, Blueprint, url_for from markupsafe import Markup from wtforms import BooleanField, HiddenField +P = ParamSpec('P') + CDN_BASE = 'https://cdn.jsdelivr.net/npm' @@ -11,11 +14,11 @@ def is_hidden_field_filter(field): return isinstance(field, HiddenField) -def raise_helper(message): +def raise_helper(message: str) -> NoReturn: raise RuntimeError(message) -def get_table_titles(data, primary_key, primary_key_title): +def get_table_titles(data: list, primary_key: str, primary_key_title: str) -> list[tuple[str, str]]: """Detect and build the table titles tuple from ORM object, currently only support SQLAlchemy. .. versionadded:: 1.4.0 @@ -285,5 +288,5 @@ class SwitchField(BooleanField): .. versionadded:: 2.0.0 """ - def __init__(self, label=None, **kwargs): + def __init__(self, label: str = None, **kwargs: P.kwargs) -> None: super().__init__(label, **kwargs)