@@ -33,9 +33,9 @@ def to_camel_case(word: str) -> str:
3333
3434
3535class QuerySet (Iterable [T ], Sized ):
36- def __init__ (self , model : "QuerysetEndpoint[T]" ) -> None :
36+ def __init__ (self , model : "QuerysetEndpoint[T]" , page_size : Optional [ int ] = None ) -> None :
3737 self .model = model
38- self .request_options = RequestOptions ()
38+ self .request_options = RequestOptions (pagesize = page_size or 100 )
3939 self ._result_cache : List [T ] = []
4040 self ._pagination_item = PaginationItem ()
4141
@@ -134,12 +134,15 @@ def page_size(self: Self) -> int:
134134 self ._fetch_all ()
135135 return self ._pagination_item .page_size
136136
137- def filter (self : Self , * invalid , ** kwargs ) -> Self :
137+ def filter (self : Self , * invalid , page_size : Optional [ int ] = None , ** kwargs ) -> Self :
138138 if invalid :
139139 raise RuntimeError ("Only accepts keyword arguments." )
140140 for kwarg_key , value in kwargs .items ():
141141 field_name , operator = self ._parse_shorthand_filter (kwarg_key )
142142 self .request_options .filter .add (Filter (field_name , operator , value ))
143+
144+ if page_size :
145+ self .request_options .pagesize = page_size
143146 return self
144147
145148 def order_by (self : Self , * args ) -> Self :
@@ -155,11 +158,8 @@ def paginate(self: Self, **kwargs) -> Self:
155158 self .request_options .pagesize = kwargs ["page_size" ]
156159 return self
157160
158- def with_page_size (self : Self , value : int ) -> Self :
159- self .request_options .pagesize = value
160- return self
161-
162- def _parse_shorthand_filter (self : Self , key : str ) -> Tuple [str , str ]:
161+ @staticmethod
162+ def _parse_shorthand_filter (key : str ) -> Tuple [str , str ]:
163163 tokens = key .split ("__" , 1 )
164164 if len (tokens ) == 1 :
165165 operator = RequestOptions .Operator .Equals
@@ -173,7 +173,8 @@ def _parse_shorthand_filter(self: Self, key: str) -> Tuple[str, str]:
173173 raise ValueError ("Field name `{}` is not valid." .format (field ))
174174 return (field , operator )
175175
176- def _parse_shorthand_sort (self : Self , key : str ) -> Tuple [str , str ]:
176+ @staticmethod
177+ def _parse_shorthand_sort (key : str ) -> Tuple [str , str ]:
177178 direction = RequestOptions .Direction .Asc
178179 if key .startswith ("-" ):
179180 direction = RequestOptions .Direction .Desc
0 commit comments