|
13 | 13 | from wtforms.widgets import Input |
14 | 14 |
|
15 | 15 | if sys.version_info >= (3, 11): |
16 | | - from typing import NotRequired # noqa |
| 16 | + from typing import NotRequired |
17 | 17 | else: |
18 | | - from typing_extensions import NotRequired # noqa |
| 18 | + from typing_extensions import NotRequired |
19 | 19 |
|
20 | 20 | if t.TYPE_CHECKING: |
21 | | - from flask_admin.base import BaseView as T_VIEW # noqa |
| 21 | + # optional dependencies |
| 22 | + from arrow import Arrow as T_ARROW # noqa |
| 23 | + from flask_babel import LazyString as T_LAZY_STRING |
| 24 | + from flask_sqlalchemy import Model as T_SQLALCHEMY_LEGACY_MODEL |
| 25 | + from sqlalchemy.orm import DeclarativeBase as T_DECLARATIVE_BASE |
| 26 | + |
| 27 | + from flask_admin.base import BaseView as T_VIEW |
22 | 28 | from flask_admin.contrib.sqla.validators import InputRequired as T_INPUT_REQUIRED |
23 | 29 | from flask_admin.contrib.sqla.validators import ( |
24 | 30 | TimeZoneValidator as T_TIMEZONE_VALIDATOR, |
25 | 31 | ) |
26 | 32 | from flask_admin.contrib.sqla.validators import Unique as T_UNIQUE |
27 | | - from flask_admin.form import FormOpts as T_FORM_OPTS # noqa |
28 | | - from flask_admin.form.rules import ( |
29 | | - FieldSet as T_FIELD_SET, |
30 | | - BaseRule as T_BASE_RULE, |
31 | | - Header as T_HEADER, |
32 | | - Field as T_FLASK_ADMIN_FIELD, |
33 | | - Macro as T_MACRO, |
34 | | - ) |
| 33 | + from flask_admin.form import FormOpts as T_FORM_OPTS |
| 34 | + from flask_admin.form.rules import BaseRule as T_BASE_RULE |
| 35 | + from flask_admin.form.rules import Field as T_FLASK_ADMIN_FIELD |
| 36 | + from flask_admin.form.rules import FieldSet as T_FIELD_SET |
| 37 | + from flask_admin.form.rules import Header as T_HEADER |
| 38 | + from flask_admin.form.rules import Macro as T_MACRO |
35 | 39 | from flask_admin.model import BaseModelView as T_MODEL_VIEW |
36 | | - from flask_admin.model.ajax import AjaxModelLoader as T_AJAX_MODEL_LOADER # noqa |
37 | | - from flask_admin.model.fields import AjaxSelectField as T_AJAX_SELECT_FIELD # noqa |
38 | | - from flask_admin.model.form import ( # noqa |
39 | | - InlineBaseFormAdmin as T_INLINE_BASE_FORM_ADMIN, |
40 | | - ) |
| 40 | + from flask_admin.model.ajax import AjaxModelLoader as T_AJAX_MODEL_LOADER |
| 41 | + from flask_admin.model.fields import AjaxSelectField as T_AJAX_SELECT_FIELD |
| 42 | + from flask_admin.model.form import InlineBaseFormAdmin as T_INLINE_BASE_FORM_ADMIN |
41 | 43 | from flask_admin.model.form import InlineFormAdmin as T_INLINE_FORM_ADMIN |
42 | 44 | from flask_admin.model.widgets import ( |
43 | | - InlineFieldListWidget as T_INLINE_FIELD_LIST_WIDGET, |
| 45 | + AjaxSelect2Widget as T_INLINE_AJAX_SELECT2_WIDGET, |
44 | 46 | ) |
45 | | - from flask_admin.model.widgets import InlineFormWidget as T_INLINE_FORM_WIDGET |
46 | 47 | from flask_admin.model.widgets import ( |
47 | | - AjaxSelect2Widget as T_INLINE_AJAX_SELECT2_WIDGET, |
| 48 | + InlineFieldListWidget as T_INLINE_FIELD_LIST_WIDGET, |
48 | 49 | ) |
| 50 | + from flask_admin.model.widgets import InlineFormWidget as T_INLINE_FORM_WIDGET |
49 | 51 | from flask_admin.model.widgets import XEditableWidget as T_INLINE_X_EDITABLE_WIDGET |
50 | 52 |
|
51 | | - # optional dependencies |
52 | | - from arrow import Arrow as T_ARROW # noqa |
53 | | - from flask_babel import LazyString as T_LAZY_STRING # noqa |
54 | | - |
55 | | - from flask_sqlalchemy import Model as T_SQLALCHEMY_LEGACY_MODEL |
56 | | - from sqlalchemy.orm import DeclarativeBase as T_DECLARATIVE_BASE |
57 | | - |
58 | 53 | T_SQLALCHEMY_MODEL: t.TypeAlias = t.Union[ |
59 | 54 | T_SQLALCHEMY_LEGACY_MODEL, T_DECLARATIVE_BASE |
60 | 55 | ] |
|
82 | 77 | T_SQLALCHEMY_COLUMN = Column # type: ignore[misc] |
83 | 78 |
|
84 | 79 | T_MONGO_CLIENT = MongoClient[t.Any] |
85 | | - from redis import Redis as T_REDIS # noqa |
| 80 | + from PIL.Image import Image as T_PIL_IMAGE |
| 81 | + from redis import Redis as T_REDIS |
| 82 | + |
86 | 83 | from flask_admin.contrib.peewee.ajax import ( |
87 | 84 | QueryAjaxModelLoader as T_PEEWEE_QUERY_AJAX_MODEL_LOADER, |
88 | | - ) # noqa |
| 85 | + ) |
89 | 86 | from flask_admin.contrib.sqla.ajax import ( |
90 | 87 | QueryAjaxModelLoader as T_SQLA_QUERY_AJAX_MODEL_LOADER, |
91 | | - ) # noqa |
92 | | - from PIL.Image import Image as T_PIL_IMAGE # noqa |
| 88 | + ) |
93 | 89 |
|
94 | 90 | T_ORM_MODEL: t.TypeAlias = t.Union[ |
95 | 91 | T_SQLALCHEMY_LEGACY_MODEL, |
@@ -278,3 +274,9 @@ def __contains__(self, key: t.Any, /) -> bool: ... |
278 | 274 |
|
279 | 275 | class _MultiDictLikeWithGetlist(_MultiDictLikeBase, t.Protocol): |
280 | 276 | def getlist(self, key: str, /) -> list[t.Any]: ... |
| 277 | + |
| 278 | + |
| 279 | +class _T_MONGOENGINE_FIELD_PROTOCOL(t.Protocol): |
| 280 | + id: t.Any |
| 281 | + data: t.Any |
| 282 | + name: str |
0 commit comments