Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 35c8f53

Browse files
calculate limit override more cleanly)
1 parent 9cfd146 commit 35c8f53

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/stapi_fastapi/routers/root_router.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def get_products(
145145
self, request: Request, next: str | None = None, limit: int = 10
146146
) -> ProductsCollection:
147147
start = 0
148+
limit = min(limit, 100)
148149
try:
149150
if next:
150151
start = self.product_ids.index(next)

tests/application.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ async def get_orders(
5050
"""
5151
try:
5252
start = 0
53-
if limit > 100:
54-
limit = 100
53+
limit = min(limit, 100)
5554
order_ids = [*self._orders_db._orders.keys()]
5655

5756
if next:
@@ -80,8 +79,7 @@ async def get_order_statuses(
8079
) -> ResultE[tuple[list[OrderStatus], Maybe[str]]]:
8180
try:
8281
start = 0
83-
if limit > 100:
84-
limit = 100
82+
limit = min(limit, 100)
8583
statuses = self._orders_db._statuses[order_id]
8684

8785
if next:
@@ -112,8 +110,7 @@ async def search_opportunities(
112110
) -> ResultE[tuple[list[Opportunity], Maybe[str]]]:
113111
try:
114112
start = 0
115-
if limit > 100:
116-
limit = 100
113+
limit = min(limit, 100)
117114
if next:
118115
start = int(next)
119116
end = start + limit

0 commit comments

Comments
 (0)