Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ Bugfixes:

Type hints:

* Type hints added to all functions and methods (some using `typing.Any` where full typing not yet available)
* Type hints added to all functions and methods (some still use `typing.Any` where full typing not yet available)
* Updated InlineBaseFormAdmin.get_form() to return type[BaseForm] | None rather than T_MODEL_VIEW | None
* Minor type hinting improvements for peewee backend
* Admin(index_view=...) now accepts a BaseView instance rather than AdminIndexView, allowing e.g. FileAdmin

2.2.0
------------------
Expand Down
8 changes: 4 additions & 4 deletions flask_admin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def __init__(
name: str | None = None,
url: str | None = None,
subdomain: str | None = None,
index_view: AdminIndexView | None = None,
index_view: BaseView | None = None,
translations_path: str | None = None,
endpoint: str | None = None,
static_url_path: str | None = None,
Expand Down Expand Up @@ -667,7 +667,7 @@ def add_view(self, view: BaseView) -> None:

def _set_admin_index_view(
self,
index_view: AdminIndexView | None = None,
index_view: BaseView | None = None,
endpoint: str | None = None,
url: str | None = None,
) -> None:
Expand All @@ -683,7 +683,7 @@ def _set_admin_index_view(
`Admin` class with a single Flask application, you have to set a unique
endpoint name for each instance.
"""
self.index_view: AdminIndexView = ( # type: ignore[no-redef]
self.index_view: BaseView = ( # type: ignore[no-redef]
index_view or AdminIndexView(endpoint=endpoint, url=url)
)
self.endpoint = endpoint or self.index_view.endpoint
Expand Down Expand Up @@ -856,7 +856,7 @@ def get_category_menu_item(self, name: str) -> MenuCategory | None:
def init_app(
self,
app: Flask,
index_view: AdminIndexView | None = None,
index_view: BaseView | None = None,
endpoint: str | None = None,
url: str | None = None,
) -> None:
Expand Down
5 changes: 4 additions & 1 deletion flask_admin/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ def test_base_defaults() -> None:
assert admin.endpoint == "admin"
assert admin.app is None
assert admin.index_view is not None
assert admin.index_view._template == "admin/index.html"
assert (
isinstance(admin.index_view, base.AdminIndexView)
and admin.index_view._template == "admin/index.html"
)

# Check if default view was added
assert len(admin._views) == 1
Expand Down