Skip to content

Commit d2682a0

Browse files
committed
start typehints
1 parent 85dd170 commit d2682a0

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

flask_bootstrap/__init__.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1+
"""TODO."""
2+
13
import warnings
4+
from typing import NoReturn, ParamSpec
25

36
from flask import current_app, Blueprint, url_for
47
from markupsafe import Markup
58
from wtforms import BooleanField, HiddenField
69

10+
P = ParamSpec('P')
11+
712
CDN_BASE = 'https://cdn.jsdelivr.net/npm'
813

914

1015
def is_hidden_field_filter(field):
16+
"""TODO."""
1117
return isinstance(field, HiddenField)
1218

1319

14-
def raise_helper(message):
20+
def raise_helper(message: str) -> NoReturn:
21+
"""TODO."""
1522
raise RuntimeError(message)
1623

1724

18-
def get_table_titles(data, primary_key, primary_key_title):
25+
def get_table_titles(data: list, primary_key: str, primary_key_title: str) -> list[tuple[str, str]]:
1926
"""Detect and build the table titles tuple from ORM object, currently only support SQLAlchemy.
2027
2128
.. versionadded:: 1.4.0
@@ -37,14 +44,14 @@ class _Bootstrap:
3744
.. versionadded:: 2.0.0
3845
"""
3946

40-
bootstrap_version = None
41-
jquery_version = None
42-
popper_version = None
43-
bootstrap_css_integrity = None
44-
bootstrap_js_integrity = None
45-
jquery_integrity = None
46-
popper_integrity = None
47-
static_folder = None
47+
bootstrap_version: str | None = None
48+
jquery_version: str | None = None
49+
popper_version: str | None = None
50+
bootstrap_css_integrity: str | None = None
51+
bootstrap_js_integrity: str | None = None
52+
jquery_integrity: str | None = None
53+
popper_integrity: str | None = None
54+
static_folder: str | None = None
4855
bootstrap_css_filename = 'bootstrap.min.css'
4956
bootstrap_js_filename = 'bootstrap.min.js'
5057
jquery_filename = 'jquery.min.js'
@@ -55,7 +62,7 @@ def __init__(self, app=None):
5562
self.init_app(app)
5663

5764
def init_app(self, app):
58-
65+
"""TODO."""
5966
if not hasattr(app, 'extensions'):
6067
app.extensions = {} # pragma: no cover
6168
app.extensions['bootstrap'] = self
@@ -269,6 +276,8 @@ def create_app():
269276

270277

271278
class Bootstrap(Bootstrap4):
279+
"""TODO."""
280+
272281
def __init__(self, app=None):
273282
super().__init__(app=app)
274283
warnings.warn(
@@ -284,6 +293,7 @@ class SwitchField(BooleanField):
284293
285294
.. versionadded:: 2.0.0
286295
"""
287-
288-
def __init__(self, label=None, **kwargs):
296+
def __init__(self, label: str | None = None,
297+
*args: P.args,
298+
**kwargs: P.kwargs) -> None:
289299
super().__init__(label, **kwargs)

0 commit comments

Comments
 (0)