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
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ i18n = [
test = [
"pytest >=8.3.0, <8.4.0",
"pytest-asyncio >=0.24.0, <0.25.0",
"mypy ==1.15.0",
"ruff ==0.11.9",
"black ==25.1.0",
"mypy ==1.19.0",
"ruff ==0.14.7",
"black ==25.11.0",
"httpx >=0.23.3, <0.29.0",
"SQLAlchemy-Utils >=0.40.0, <0.42.0",
"sqlmodel >=0.0.11, <0.1.0",
Expand Down Expand Up @@ -123,6 +123,7 @@ matrix.sqla_version.dependencies = [
{ value = "SQLAlchemy[asyncio] >=2.0, <2.1", if = ["sqla2"] },
{ value = "odmantic >=1.0.0,<1.1.0", if = ["sqla2"] },
{ value = "SQLAlchemy[asyncio] >=1.4, <1.5", if = ["sqla14"] },
{ value = "sqlmodel >=0.0.11, <0.0.26", if = ["sqla14"] },
]
matrix.sqla_version.scripts = [
{ key = "all", value = 'coverage run -m pytest tests --ignore=tests/odmantic --ignore=tests/beanie', if = ["sqla14"] },
Expand Down Expand Up @@ -217,7 +218,8 @@ lint.ignore = [
"B008", # Do not perform function call `_` in argument defaults, neccessary for lazy_gettext
"B905", # `zip()` without an explicit `strict=` parameter
"E501", # line too long, handled by black
"N818", # Exception {name} should be named with an Error suffix
"N818", # Exception {name} should be named with an Error suffix,
"PLC0415", # `import` should be at the top-level of a file
]
target-version = "py38"

Expand All @@ -244,6 +246,7 @@ ignore_missing_imports = true
[[tool.mypy.overrides]]
module = [
"starlette_admin.contrib.sqla.helpers",
"starlette_admin.contrib.sqla.converters",
"starlette_admin.contrib.sqla.view",
"starlette_admin.contrib.odmantic.helpers",
"starlette_admin.contrib.odmantic.view",
Expand Down
4 changes: 2 additions & 2 deletions starlette_admin/contrib/mongoengine/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
resolve_deep_query,
)
from starlette_admin.exceptions import FormValidationError
from starlette_admin.helpers import prettify_class_name, slugify_class_name
from starlette_admin.helpers import not_none, prettify_class_name, slugify_class_name
from starlette_admin.views import BaseModelView


Expand Down Expand Up @@ -135,7 +135,7 @@ async def _populate_obj( # noqa: C901
me_field = getattr(document, name)
if isinstance(field, (FileField, ImageField)):
proxy: GridFSProxy = getattr(obj, name)
value, should_be_deleted = value
value, should_be_deleted = not_none(value)
if should_be_deleted:
proxy.delete()
elif isinstance(value, UploadFile):
Expand Down
4 changes: 2 additions & 2 deletions starlette_admin/contrib/sqla/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ async def _populate_obj(
for field in self.get_fields_list(request, request.state.action):
name, value = field.name, data.get(field.name, None)
if isinstance(field, FileField):
value, should_be_deleted = value
value, should_be_deleted = not_none(value)
if should_be_deleted:
setattr(obj, name, None)
elif (not field.multiple and value is not None) or (
Expand Down Expand Up @@ -602,7 +602,7 @@ def build_order_clauses(
stmt = stmt.outerjoin(model_attr)
sorting_attr = self.sortable_field_mapping.get(attr_key, model_attr)
stmt = stmt.order_by(
not_none(sorting_attr).desc()
not_none(sorting_attr).desc() # type: ignore [attr-defined]
if order.lower() == "desc"
else sorting_attr
)
Expand Down
2 changes: 1 addition & 1 deletion tests/mongoengine/test_view_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class CustomDocumentView(ModelView):

def test_invalid_exclude_list():
with pytest.raises(
ValueError, match="Expected str or monogoengine.BaseField, got int"
ValueError, match=r"Expected str or monogoengine.BaseField, got int"
):

class CustomDocumentView(ModelView):
Expand Down