muffin-rest 13.1.0__tar.gz → 13.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/PKG-INFO +1 -1
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/filters.py +3 -3
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/handler.py +3 -3
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/filters.py +4 -2
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/pyproject.toml +2 -2
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/README.md +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/__init__.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/api.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/errors.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/limits.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/marshmallow.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/mongo/__init__.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/mongo/filters.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/mongo/schema.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/mongo/sorting.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/mongo/types.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/mongo/utils.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/openapi.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/options.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/__init__.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/handler.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/openapi.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/options.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/schemas.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/sorting.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/types.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/peewee/utils.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/py.typed +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/redoc.html +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/schemas.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/sorting.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/sqlalchemy/__init__.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/sqlalchemy/filters.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/sqlalchemy/sorting.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/sqlalchemy/types.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/swagger.html +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/types.py +0 -0
- {muffin_rest-13.1.0 → muffin_rest-13.1.2}/muffin_rest/utils.py +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import operator
|
|
6
|
-
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Iterable, Mapping
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Iterable, Mapping, cast
|
|
7
7
|
|
|
8
8
|
import marshmallow as ma
|
|
9
9
|
from asgi_tools._compat import json_loads
|
|
@@ -90,13 +90,13 @@ class Filter(Mutate):
|
|
|
90
90
|
|
|
91
91
|
return ops, collection
|
|
92
92
|
|
|
93
|
-
async def filter(self, collection, *ops: TFilterValue) ->
|
|
93
|
+
async def filter(self, collection: TVCollection, *ops: TFilterValue) -> TVCollection:
|
|
94
94
|
"""Apply the filter to collection."""
|
|
95
95
|
|
|
96
96
|
def validator(obj):
|
|
97
97
|
return all(op(get_value(obj, self.name), val) for op, val in ops)
|
|
98
98
|
|
|
99
|
-
return [item for item in collection if validator(item)]
|
|
99
|
+
return cast("TVCollection", [item for item in collection if validator(item)])
|
|
100
100
|
|
|
101
101
|
def get_simple_value(self, ops: TFilterOps) -> Any:
|
|
102
102
|
"""Get simple value from filter's data.
|
|
@@ -64,12 +64,12 @@ class RESTBase(Handler, Generic[TVResource], metaclass=RESTHandlerMeta):
|
|
|
64
64
|
class Meta:
|
|
65
65
|
"""Tune the handler."""
|
|
66
66
|
|
|
67
|
-
# Resource filters
|
|
68
|
-
filters: Sequence[str | tuple[str, str] | Filter] = ()
|
|
69
|
-
|
|
70
67
|
# Define allowed resource sorting params
|
|
71
68
|
sorting: Sequence[str | tuple[str, dict] | Sort] = ()
|
|
72
69
|
|
|
70
|
+
# Resource filters
|
|
71
|
+
filters: Sequence[str | tuple[str, dict] | Filter] = ()
|
|
72
|
+
|
|
73
73
|
# Serialize/Deserialize Schema class
|
|
74
74
|
Schema: type[ma.Schema] | None = None
|
|
75
75
|
|
|
@@ -6,7 +6,7 @@ import operator
|
|
|
6
6
|
from functools import reduce
|
|
7
7
|
from typing import TYPE_CHECKING, ClassVar, cast
|
|
8
8
|
|
|
9
|
-
from peewee import ColumnBase, Field
|
|
9
|
+
from peewee import ColumnBase, Field
|
|
10
10
|
|
|
11
11
|
from muffin_rest.filters import Filter, Filters
|
|
12
12
|
|
|
@@ -39,11 +39,13 @@ class PWFilter(Filter):
|
|
|
39
39
|
|
|
40
40
|
list_ops = (*Filter.list_ops, "$between")
|
|
41
41
|
|
|
42
|
-
async def filter(self, collection
|
|
42
|
+
async def filter(self, collection, *ops: TFilterValue):
|
|
43
43
|
"""Apply the filters to Peewee QuerySet.."""
|
|
44
44
|
column = self.field
|
|
45
|
+
|
|
45
46
|
if isinstance(column, ColumnBase):
|
|
46
47
|
collection = collection.where(*[op(column, val) for op, val in ops])
|
|
48
|
+
|
|
47
49
|
return collection
|
|
48
50
|
|
|
49
51
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "muffin-rest"
|
|
3
|
-
version = "13.1.
|
|
3
|
+
version = "13.1.2"
|
|
4
4
|
description = "The package provides enhanced support for writing REST APIs with Muffin framework"
|
|
5
5
|
authors = [{ name = "Kirill Klenov", email = "horneds@gmail.com" }]
|
|
6
6
|
requires-python = ">=3.10,<4"
|
|
@@ -114,7 +114,7 @@ ignore = [
|
|
|
114
114
|
]
|
|
115
115
|
|
|
116
116
|
[tool.bumpversion]
|
|
117
|
-
current_version = "13.1.
|
|
117
|
+
current_version = "13.1.2"
|
|
118
118
|
commit = false
|
|
119
119
|
tag = false
|
|
120
120
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|