Skip to content

Commit 69c4dc9

Browse files
authored
Remove conditional APIs from indexes (#744)
1 parent 8ed6379 commit 69c4dc9

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

pynamodb/indexes.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def count(cls,
5050
range_key_condition=None,
5151
filter_condition=None,
5252
consistent_read=False,
53-
**filters):
53+
limit=None,
54+
rate_limit=None):
5455
"""
5556
Count on an index
5657
"""
@@ -60,34 +61,37 @@ def count(cls,
6061
filter_condition=filter_condition,
6162
index_name=cls.Meta.index_name,
6263
consistent_read=consistent_read,
63-
**filters
64+
limit=limit,
65+
rate_limit=rate_limit,
6466
)
6567

6668
@classmethod
6769
def query(self,
6870
hash_key,
6971
range_key_condition=None,
7072
filter_condition=None,
71-
scan_index_forward=None,
7273
consistent_read=False,
74+
scan_index_forward=None,
7375
limit=None,
7476
last_evaluated_key=None,
7577
attributes_to_get=None,
76-
**filters):
78+
page_size=None,
79+
rate_limit=None):
7780
"""
7881
Queries an index
7982
"""
8083
return self.Meta.model.query(
8184
hash_key,
8285
range_key_condition=range_key_condition,
8386
filter_condition=filter_condition,
87+
consistent_read=consistent_read,
8488
index_name=self.Meta.index_name,
8589
scan_index_forward=scan_index_forward,
86-
consistent_read=consistent_read,
8790
limit=limit,
8891
last_evaluated_key=last_evaluated_key,
8992
attributes_to_get=attributes_to_get,
90-
**filters
93+
page_size=page_size,
94+
rate_limit=rate_limit,
9195
)
9296

9397
@classmethod
@@ -99,8 +103,8 @@ def scan(self,
99103
last_evaluated_key=None,
100104
page_size=None,
101105
consistent_read=None,
102-
attributes_to_get=None,
103-
**filters):
106+
rate_limit=None,
107+
attributes_to_get=None):
104108
"""
105109
Scans an index
106110
"""
@@ -113,8 +117,8 @@ def scan(self,
113117
page_size=page_size,
114118
consistent_read=consistent_read,
115119
index_name=self.Meta.index_name,
120+
rate_limit=rate_limit,
116121
attributes_to_get=attributes_to_get,
117-
**filters
118122
)
119123

120124
@classmethod

pynamodb/indexes.pyi

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,37 @@ from pynamodb.pagination import ResultIterator
55

66
_T = TypeVar('_T', bound='Index')
77

8+
89
class IndexMeta(type):
910
def __init__(cls, name, bases, attrs) -> None: ...
1011

12+
1113
class Index(metaclass=IndexMeta):
1214
Meta: Any
1315
def __init__(self) -> None: ...
1416
@classmethod
15-
def count(cls, hash_key, consistent_read: bool = ..., **filters) -> int: ...
17+
def count(
18+
cls,
19+
hash_key,
20+
range_key_condition: Optional[Condition] = ...,
21+
filter_condition: Optional[Condition] = ...,
22+
consistent_read: bool = ...,
23+
limit: Optional[int] = ...,
24+
rate_limit: Optional[float] = ...,
25+
) -> int: ...
1626
@classmethod
1727
def query(
1828
cls: Type[_T],
1929
hash_key,
30+
range_key_condition: Optional[Condition] = ...,
31+
filter_condition: Optional[Condition] = ...,
2032
scan_index_forward: Optional[Any] = ...,
2133
consistent_read: Optional[bool] = ...,
22-
limit: Optional[Any] = ...,
34+
limit: Optional[int] = ...,
2335
last_evaluated_key: Optional[Dict[Text, Dict[Text, Any]]] = ...,
2436
attributes_to_get: Optional[Any] = ...,
25-
**filters,
37+
page_size: Optional[int] = ...,
38+
rate_limit: Optional[float] = ...,
2639
) -> ResultIterator[_T]: ...
2740
@classmethod
2841
def scan(
@@ -34,8 +47,8 @@ class Index(metaclass=IndexMeta):
3447
last_evaluated_key: Optional[Dict[str, Dict[str, Any]]] = ...,
3548
page_size: Optional[int] = ...,
3649
consistent_read: Optional[bool] = ...,
50+
rate_limit: Optional[float] = ...,
3751
attributes_to_get: Optional[List[str]] = ...,
38-
**filters,
3952
) -> ResultIterator[_T]: ...
4053

4154
class GlobalSecondaryIndex(Index): ...

0 commit comments

Comments
 (0)