Skip to content

Commit

Permalink
start typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
PanderMusubi committed Oct 7, 2023
1 parent 85dd170 commit d2682a0
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions flask_bootstrap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
"""TODO."""

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'


def is_hidden_field_filter(field):
"""TODO."""
return isinstance(field, HiddenField)


def raise_helper(message):
def raise_helper(message: str) -> NoReturn:
"""TODO."""
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
Expand All @@ -37,14 +44,14 @@ class _Bootstrap:
.. versionadded:: 2.0.0
"""

bootstrap_version = None
jquery_version = None
popper_version = None
bootstrap_css_integrity = None
bootstrap_js_integrity = None
jquery_integrity = None
popper_integrity = None
static_folder = None
bootstrap_version: str | None = None
jquery_version: str | None = None
popper_version: str | None = None
bootstrap_css_integrity: str | None = None
bootstrap_js_integrity: str | None = None
jquery_integrity: str | None = None
popper_integrity: str | None = None
static_folder: str | None = None
bootstrap_css_filename = 'bootstrap.min.css'
bootstrap_js_filename = 'bootstrap.min.js'
jquery_filename = 'jquery.min.js'
Expand All @@ -55,7 +62,7 @@ def __init__(self, app=None):
self.init_app(app)

def init_app(self, app):

"""TODO."""
if not hasattr(app, 'extensions'):
app.extensions = {} # pragma: no cover
app.extensions['bootstrap'] = self
Expand Down Expand Up @@ -269,6 +276,8 @@ def create_app():


class Bootstrap(Bootstrap4):
"""TODO."""

def __init__(self, app=None):
super().__init__(app=app)
warnings.warn(
Expand All @@ -284,6 +293,7 @@ class SwitchField(BooleanField):
.. versionadded:: 2.0.0
"""

def __init__(self, label=None, **kwargs):
def __init__(self, label: str | None = None,
*args: P.args,
**kwargs: P.kwargs) -> None:
super().__init__(label, **kwargs)

0 comments on commit d2682a0

Please sign in to comment.