muffin-rest 13.1.0__py3-none-any.whl → 13.1.1__py3-none-any.whl

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/filters.py CHANGED
@@ -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) -> Any:
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.
@@ -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, ModelSelect
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: ModelSelect, *ops: TFilterValue) -> ModelSelect:
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
  Metadata-Version: 2.4
2
2
  Name: muffin-rest
3
- Version: 13.1.0
3
+ Version: 13.1.1
4
4
  Summary: The package provides enhanced support for writing REST APIs with Muffin framework
5
5
  Keywords: rest,api,muffin,asgi,asyncio,trio
6
6
  Author: Kirill Klenov
@@ -1,7 +1,7 @@
1
1
  muffin_rest/__init__.py,sha256=JnwsHQNDmJpOqETeIjjPheG891T5WQ0JBaiEV72Wcmg,1242
2
2
  muffin_rest/api.py,sha256=bdbXMPiZi5yXf7_u3XB_gaGDHZKzDPqnnFnrwHoO1Rs,3799
3
3
  muffin_rest/errors.py,sha256=Todg7CrCE1ufOsyyARI2Bv-RqNPH4Rl1p-Tkpq7VYrA,1151
4
- muffin_rest/filters.py,sha256=BMjH9Yai1dywvXWSR1pBMxYWE16TLKV9kB3PHNfTaRY,5928
4
+ muffin_rest/filters.py,sha256=5-tBwUtHu1wOgTEPkYC_IN0fzbWu8jpYYLSfdXTlXgQ,5979
5
5
  muffin_rest/handler.py,sha256=Ob7viBiCf8ju7XEyCMw1mG3tbWnGhgPAnCO-XtKTOEc,10723
6
6
  muffin_rest/limits.py,sha256=X6qwuQPUdKJiPRgiKLY2NquXZlrpbx7BYHH3njw9ros,2168
7
7
  muffin_rest/marshmallow.py,sha256=-MyMKiaMTfiWw4y-4adpfoQd05HV1vEKqSXJh8eD3xg,548
@@ -14,7 +14,7 @@ muffin_rest/mongo/utils.py,sha256=NEfg_BLn15BbpM7-XomfgM2fwkcNb_QBzw2r51EGbJE,39
14
14
  muffin_rest/openapi.py,sha256=mFJ2K-I6K2WD2QoZL8ozmtLqGd3pCHv3s9VKNUK5NbY,8656
15
15
  muffin_rest/options.py,sha256=Mzv0mq6YylL6cNtad9JhEhkmA4RgmDsu-On2hn5VEiw,2208
16
16
  muffin_rest/peewee/__init__.py,sha256=94DSj_ftT6fbPksHlBv40AH2HWaiZommUFOMN2jd9a4,129
17
- muffin_rest/peewee/filters.py,sha256=T_Gspasump_4Jn1dy-sE-wHpfqH94lB4K2moVtARrX8,2427
17
+ muffin_rest/peewee/filters.py,sha256=Y5DUZ4BrenVB3iWENAQ7ZUbyVdPzWn-qzCNNIq0YS0E,2388
18
18
  muffin_rest/peewee/handler.py,sha256=iDEgPPxSC-Y11MTcSl-Hs9iNWgOeQv-mU1tx-6OAe5E,5360
19
19
  muffin_rest/peewee/openapi.py,sha256=Jp_wtKNRCCjpaElJGxPtF5JYIv_hlx9S2LYT0FcxamI,1119
20
20
  muffin_rest/peewee/options.py,sha256=iLZ4ORF8T6i9aUNU2C5F-TAwwd7hW80N6wC9FztvT_o,1428
@@ -33,6 +33,6 @@ muffin_rest/sqlalchemy/types.py,sha256=Exm-zAQCtPAwXvYcCTtPRqSa-wTEWRcH_v2YSsJkB
33
33
  muffin_rest/swagger.html,sha256=2uGLu_KpkYf925KnDKHBJmV9pm6OHn5C3BWScESsUS8,1736
34
34
  muffin_rest/types.py,sha256=5NY9gPTIptv6U2Qab2xMXlS_jZuTuR0bquFFwWRURcA,510
35
35
  muffin_rest/utils.py,sha256=71hDcTVUClNN6l8bfxzCBy4IbiO2vo0b5EeMEj61n_w,2119
36
- muffin_rest-13.1.0.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
37
- muffin_rest-13.1.0.dist-info/METADATA,sha256=x7P0mJbUe-UDcqHp-AeayK_BRWHbIQ_Q3nDrtsuF3RE,4982
38
- muffin_rest-13.1.0.dist-info/RECORD,,
36
+ muffin_rest-13.1.1.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
37
+ muffin_rest-13.1.1.dist-info/METADATA,sha256=UWCjQTEgOM55e868Ew82njofDd2kB1yV4ZVVlhPasL0,4982
38
+ muffin_rest-13.1.1.dist-info/RECORD,,