Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_path_param_le_ge(item_id: float = Path(..., le=3, ge=1)):
return item_id
def get_path_param_ge(item_id: float = Path(..., ge=3)):
return item_id
def get_path_param_gt_int(item_id: int = Path(..., gt=3)):
return item_id
def get_path_param_lt_gt_int(item_id: int = Path(..., lt=3, gt=1)):
return item_id
async def get_comment_by_id_from_path(
comment_id: int = Path(..., ge=1),
article: Article = Depends(articles.get_article_by_slug_from_path),
user: Optional[User] = Depends(
authentication.get_current_user_authorizer(required=False)
),
comments_repo: CommentsRepository = Depends(
database.get_repository(CommentsRepository)
),
) -> Comment:
try:
return await comments_repo.get_comment_by_id(
comment_id=comment_id, article=article, user=user
)
except EntityDoesNotExist:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail=strings.COMMENT_DOES_NOT_EXIST
)
async def read_items(
item_id: int = Path(..., title="The ID of the item to get"),
q: str = Query(None, alias="item-query"),
):
results = {"item_id": item_id}
if q:
results.update({"q": q})
return results
async def read_items(
q: str, item_id: int = Path(..., title="The ID of the item to get")
):
results = {"item_id": item_id}
if q:
results.update({"q": q})
return results
async def read_items(
*, item_id: int = Path(..., title="The ID of the item to get", ge=1), q: str
):
results = {"item_id": item_id}
if q:
results.update({"q": q})
return results
async def delete_comment_from_article(
slug: str = Path(..., min_length=1),
id: int = Path(..., ge=1),
user: User = Depends(get_current_user_authorizer()),
db: DataBase = Depends(get_database),
):
async with db.pool.acquire() as conn:
await get_article_or_404(conn, slug, user.username)
await delete_comment(conn, id, user.username)
async def read_items(
*,
item_id: int = Path(..., title="The ID of the item to get", ge=0, le=1000),
q: str,
size: float = Query(..., gt=0, lt=10.5)
):
results = {"item_id": item_id}
if q:
results.update({"q": q})
return results